github.com/crowdsecurity/crowdsec@v1.6.1/.github/workflows/publish-docker.yml (about) 1 name: (sub) Publish Docker images 2 3 on: 4 workflow_call: 5 secrets: 6 DOCKER_USERNAME: 7 required: true 8 DOCKER_PASSWORD: 9 required: true 10 inputs: 11 platform: 12 required: true 13 type: string 14 image_version: 15 required: true 16 type: string 17 crowdsec_version: 18 required: true 19 type: string 20 latest: 21 required: true 22 type: boolean 23 push: 24 required: true 25 type: boolean 26 slim: 27 required: true 28 type: boolean 29 debian: 30 required: true 31 type: boolean 32 33 jobs: 34 push_to_registry: 35 name: Push Docker image to registries 36 runs-on: ubuntu-latest 37 steps: 38 39 - name: Check out the repo 40 uses: actions/checkout@v4 41 with: 42 fetch-depth: 0 43 44 - name: Set up QEMU 45 uses: docker/setup-qemu-action@v3 46 47 - name: Set up Docker Buildx 48 uses: docker/setup-buildx-action@v3 49 with: 50 config: .github/buildkit.toml 51 52 - name: Login to DockerHub 53 uses: docker/login-action@v3 54 with: 55 username: ${{ secrets.DOCKER_USERNAME }} 56 password: ${{ secrets.DOCKER_PASSWORD }} 57 58 - name: Login to GitHub Container Registry 59 uses: docker/login-action@v3 60 with: 61 registry: ghcr.io 62 username: ${{ github.repository_owner }} 63 password: ${{ secrets.GITHUB_TOKEN }} 64 65 - name: Prepare (slim) 66 if: ${{ inputs.slim }} 67 id: slim 68 run: | 69 DOCKERHUB_IMAGE=${{ secrets.DOCKER_USERNAME }}/crowdsec 70 GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/crowdsec 71 VERSION=${{ inputs.image_version }} 72 DEBIAN=${{ inputs.debian && '-debian' || '' }} 73 TAGS="${DOCKERHUB_IMAGE}:${VERSION}-slim${DEBIAN},${GHCR_IMAGE}:${VERSION}-slim${DEBIAN}" 74 if [[ ${{ inputs.latest }} == true ]]; then 75 TAGS=$TAGS,${DOCKERHUB_IMAGE}:slim${DEBIAN},${GHCR_IMAGE}:slim${DEBIAN} 76 fi 77 echo "tags=${TAGS}" >> $GITHUB_OUTPUT 78 echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT 79 80 - name: Prepare (full) 81 id: full 82 run: | 83 DOCKERHUB_IMAGE=${{ secrets.DOCKER_USERNAME }}/crowdsec 84 GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/crowdsec 85 VERSION=${{ inputs.image_version }} 86 DEBIAN=${{ inputs.debian && '-debian' || '' }} 87 TAGS="${DOCKERHUB_IMAGE}:${VERSION}${DEBIAN},${GHCR_IMAGE}:${VERSION}${DEBIAN}" 88 if [[ ${{ inputs.latest }} == true ]]; then 89 TAGS=$TAGS,${DOCKERHUB_IMAGE}:latest${DEBIAN},${GHCR_IMAGE}:latest${DEBIAN} 90 fi 91 echo "tags=${TAGS}" >> $GITHUB_OUTPUT 92 echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT 93 94 - name: Build and push image (slim) 95 if: ${{ inputs.slim }} 96 uses: docker/build-push-action@v5 97 with: 98 context: . 99 file: ./Dockerfile${{ inputs.debian && '.debian' || '' }} 100 push: ${{ inputs.push }} 101 tags: ${{ steps.slim.outputs.tags }} 102 target: slim 103 platforms: ${{ inputs.platform }} 104 labels: | 105 org.opencontainers.image.source=${{ github.event.repository.html_url }} 106 org.opencontainers.image.created=${{ steps.slim.outputs.created }} 107 org.opencontainers.image.revision=${{ github.sha }} 108 build-args: | 109 BUILD_VERSION=${{ inputs.crowdsec_version }} 110 111 - name: Build and push image (full) 112 uses: docker/build-push-action@v5 113 with: 114 context: . 115 file: ./Dockerfile${{ inputs.debian && '.debian' || '' }} 116 push: ${{ inputs.push }} 117 tags: ${{ steps.full.outputs.tags }} 118 target: full 119 platforms: ${{ inputs.platform }} 120 labels: | 121 org.opencontainers.image.source=${{ github.event.repository.html_url }} 122 org.opencontainers.image.created=${{ steps.full.outputs.created }} 123 org.opencontainers.image.revision=${{ github.sha }} 124 build-args: | 125 BUILD_VERSION=${{ inputs.crowdsec_version }}