|
| 1 | +name: Docker build and publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +concurrency: |
| 8 | + # We want all containers to be pushed. Don't cancel any concurent jobs. |
| 9 | + group: '${{ github.workflow }} @ ${{ github.sha}}' |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + docker: |
| 14 | + runs-on: ubuntu-24.04 |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + submodules: 'recursive' |
| 20 | + - name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v3 |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: docker/setup-buildx-action@v3 |
| 24 | + - name: Login to Docker Hub |
| 25 | + if: github.event_name != 'pull_request' |
| 26 | + uses: docker/login-action@v3 |
| 27 | + with: |
| 28 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 29 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 30 | + - name: Get short SHA |
| 31 | + id: sha |
| 32 | + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 33 | + - name: Generate image metadata |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@v5 |
| 36 | + env: |
| 37 | + # We build multiplatform images which have an image index above the |
| 38 | + # image manifests. Attach the annotations directly to the image index. |
| 39 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: "index" |
| 40 | + |
| 41 | + - name: Build and push |
| 42 | + if: github.event_name != 'pull_request' |
| 43 | + uses: docker/build-push-action@v6 |
| 44 | + with: |
| 45 | + context: . |
| 46 | + target: runtime |
| 47 | + platforms: linux/amd64,linux/arm64 |
| 48 | + push: true |
| 49 | + # We have to explicitly add the "qlever-petrimaps:latest" tag for it to work correctly, |
| 50 | + # see e.g. https://stackoverflow.com/questions/27643017/do-i-need-to-manually-tag-latest-when-pushing-to-docker-public-repository |
| 51 | + tags: > |
| 52 | + adfreiburg/qlever-petrimaps:latest, |
| 53 | + adfreiburg/qlever-petrimaps:${{ github.ref_name }}, |
| 54 | + adfreiburg/qlever-petrimaps:commit-${{ steps.sha.outputs.sha_short }}, |
| 55 | +
|
| 56 | + # Set annotations and labels that conform to the OpenContainers |
| 57 | + # Annotations Spec |
| 58 | + annotations: ${{ steps.meta.outputs.annotations }} |
| 59 | + labels: ${{ steps.meta.outputs.labels }} |
| 60 | + |
0 commit comments