|
| 1 | +name: Publish to GHCR.io |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +env: |
| 6 | + REGISTRY: ghcr.io |
| 7 | + IMAGE_NAME: ${{ github.repository }} |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_tag_push_to_ghcr: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 19 | + |
| 20 | + |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 |
| 23 | + |
| 24 | + - name: Setup Docker buildx |
| 25 | + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 |
| 26 | + |
| 27 | + - name: Log into registry ${{ env.REGISTRY }} |
| 28 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 |
| 29 | + with: |
| 30 | + registry: ${{ env.REGISTRY }} |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + |
| 34 | + - name: Extract Docker metadata |
| 35 | + id: meta |
| 36 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 37 | + with: |
| 38 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 40 | + tags: | |
| 41 | + type=ref,event=branch,prefix= |
| 42 | + type=ref,event=tag,prefix= |
| 43 | + type=sha,format=short,prefix= |
| 44 | + type=sha,format=long,prefix= |
| 45 | +
|
| 46 | + - name: Build and push Docker image |
| 47 | + id: build-and-push |
| 48 | + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 |
| 49 | + with: |
| 50 | + context: . |
| 51 | + push: ${{ github.event_name != 'pull_request' }} |
| 52 | + tags: ${{ steps.meta.outputs.tags }} |
| 53 | + labels: ${{ steps.meta.outputs.labels }} |
| 54 | + provenance: false |
| 55 | + cache-from: type=gha |
| 56 | + cache-to: type=gha,mode=max |
0 commit comments