|
| 1 | +name: Publish Docker image |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + |
| 9 | +permissions: |
| 10 | + actions: write # Necessary to cancel workflow executions |
| 11 | + checks: write # Necessary to write reports |
| 12 | + pull-requests: write # Necessary to comment on PRs |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + publish: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Read version |
| 24 | + run: echo VERSION=$(cat package.json | jq -r '.version') >> $GITHUB_ENV |
| 25 | + |
| 26 | + - name: Docker meta |
| 27 | + id: meta |
| 28 | + uses: docker/metadata-action@v5 |
| 29 | + with: |
| 30 | + images: | |
| 31 | + ghcr.io/inato/custom-instrumentations-node/custom-instrumentations-nodejs |
| 32 | + tags: | |
| 33 | + type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }} |
| 34 | +
|
| 35 | + - name: Set up QEMU |
| 36 | + uses: docker/setup-qemu-action@v3 |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Cache Docker layers |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: /tmp/.buildx-cache |
| 45 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-buildx- |
| 48 | +
|
| 49 | + - name: Login to GitHub Package Registry |
| 50 | + uses: docker/login-action@v3 |
| 51 | + with: |
| 52 | + registry: ghcr.io |
| 53 | + username: ${{ github.repository_owner }} |
| 54 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Build and push |
| 57 | + uses: docker/build-push-action@v6 |
| 58 | + with: |
| 59 | + context: . |
| 60 | + platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le |
| 61 | + push: true |
| 62 | + build-args: version=${{ env.VERSION }} |
| 63 | + tags: ${{ steps.meta.outputs.tags }} |
| 64 | + labels: ${{ steps.meta.outputs.labels }} |
| 65 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 66 | + cache-to: type=local,dest=/tmp/.buildx-cache |
0 commit comments