|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +jobs: |
| 7 | + docker-image: |
| 8 | + name: Build Docker Image |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + env: |
| 12 | + PUBLIC_IMAGE_PREFIX: 'datastewardshipwizard' |
| 13 | + DOCKER_IMAGE_NAME: 'replies-importer-plugin' |
| 14 | + DOCKER_META_CONTEXT: '.' |
| 15 | + DOCKER_META_FILE: 'Dockerfile' |
| 16 | + DOCKER_META_PLATFORMS: 'linux/amd64,linux/arm64' |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: '[setup] Check out repository' |
| 20 | + uses: actions/checkout@v6 |
| 21 | + |
| 22 | + - name: '[setup] Set up QEMU' |
| 23 | + uses: docker/setup-qemu-action@v3 |
| 24 | + |
| 25 | + - name: '[setup] Set up Docker Buildx' |
| 26 | + id: buildx |
| 27 | + uses: docker/setup-buildx-action@v3 |
| 28 | + |
| 29 | + - name: '[docker] Docker meta' |
| 30 | + id: meta-test |
| 31 | + uses: docker/metadata-action@v5 |
| 32 | + with: |
| 33 | + images: | |
| 34 | + ${{ env.PUBLIC_IMAGE_PREFIX }}/${{ env.DOCKER_IMAGE_NAME }} |
| 35 | + tags: | |
| 36 | + type=sha |
| 37 | +
|
| 38 | + - name: '[docker] Docker build' |
| 39 | + uses: docker/build-push-action@v6 |
| 40 | + with: |
| 41 | + context: ${{ env.DOCKER_META_CONTEXT }} |
| 42 | + file: ${{ env.DOCKER_META_FILE }} |
| 43 | + platforms: ${{ env.DOCKER_META_PLATFORMS }} |
| 44 | + push: false |
| 45 | + tags: ${{ steps.meta-test.outputs.tags }} |
| 46 | + labels: ${{ steps.meta-test.outputs.labels }} |
| 47 | + |
| 48 | + - name: '[docker-hub] Docker login' |
| 49 | + if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' |
| 50 | + uses: docker/login-action@v3 |
| 51 | + with: |
| 52 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 53 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 54 | + |
| 55 | + - name: '[docker-hub] Docker meta' |
| 56 | + id: meta-public |
| 57 | + if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' |
| 58 | + uses: docker/metadata-action@v5 |
| 59 | + with: |
| 60 | + images: | |
| 61 | + ${{ env.PUBLIC_IMAGE_PREFIX }}/${{ env.DOCKER_IMAGE_NAME }} |
| 62 | + tags: | |
| 63 | + type=ref,event=branch |
| 64 | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} |
| 65 | + type=semver,pattern={{version}} |
| 66 | + type=semver,pattern={{major}}.{{minor}} |
| 67 | + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} |
| 68 | +
|
| 69 | + - name: '[docker-hub] Docker build+push' |
| 70 | + uses: docker/build-push-action@v6 |
| 71 | + if: github.event_name != 'pull_request' && steps.meta-public.outputs.tags != '' |
| 72 | + with: |
| 73 | + context: ${{ env.DOCKER_META_CONTEXT }} |
| 74 | + file: ${{ env.DOCKER_META_FILE }} |
| 75 | + platforms: ${{ env.DOCKER_META_PLATFORMS }} |
| 76 | + push: true |
| 77 | + tags: ${{ steps.meta-public.outputs.tags }} |
| 78 | + labels: ${{ steps.meta-public.outputs.labels }} |
0 commit comments