|
1 | 1 | name: Build Docker Image |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [published] |
6 | | - push: |
7 | | - branches: |
8 | | - - master |
9 | | - pull_request: |
10 | | - types: [opened, synchronize, reopened] |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + pull_request: |
| 10 | + types: [opened, synchronize, reopened] |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - build-and-push: |
14 | | - runs-on: ubuntu-latest |
15 | | - permissions: |
16 | | - contents: read |
17 | | - packages: write |
18 | | - |
19 | | - steps: |
20 | | - - name: Checkout code |
21 | | - uses: actions/checkout@v4 |
22 | | - |
23 | | - - name: Set up Docker Buildx |
24 | | - uses: docker/setup-buildx-action@v3 |
25 | | - |
26 | | - - name: Log in to GitHub Container Registry (ghcr.io) |
27 | | - uses: docker/login-action@v3 |
28 | | - with: |
29 | | - registry: ghcr.io |
30 | | - username: ${{ github.actor }} |
31 | | - password: ${{ secrets.GITHUB_TOKEN }} |
32 | | - |
33 | | - - name: Set Docker image tags |
34 | | - id: meta |
35 | | - run: | |
36 | | - REPO=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
37 | | -
|
38 | | - if [[ "${{ github.event_name }}" == "release" ]]; then |
39 | | - VERSION_TAG=${{ github.event.release.tag_name }} |
40 | | - echo "tags<<EOF" >> $GITHUB_OUTPUT |
41 | | - echo "${REPO}:${VERSION_TAG}" >> $GITHUB_OUTPUT |
42 | | - echo "${REPO}:latest" >> $GITHUB_OUTPUT |
43 | | - echo "EOF" >> $GITHUB_OUTPUT |
44 | | -
|
45 | | - elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
46 | | - PR_NUMBER=${{ github.event.pull_request.number }} |
47 | | - echo "tags=${REPO}:pr-${PR_NUMBER}" >> $GITHUB_OUTPUT |
48 | | -
|
49 | | - else |
50 | | - echo "tags=${REPO}:dev" >> $GITHUB_OUTPUT |
51 | | - fi |
52 | | -
|
53 | | - - name: Build and push multi-platform image |
54 | | - uses: docker/build-push-action@v6 |
55 | | - with: |
56 | | - context: . |
57 | | - platforms: linux/amd64,linux/arm64 |
58 | | - push: true |
59 | | - tags: ${{ steps.meta.outputs.tags }} |
60 | | - provenance: false |
61 | | - cache-from: type=gha |
62 | | - cache-to: type=gha,mode=max |
| 13 | + build-and-push: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + packages: write |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v3 |
| 25 | + |
| 26 | + - name: Log in to GitHub Container Registry (ghcr.io) |
| 27 | + uses: docker/login-action@v3 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Set Docker image tags |
| 34 | + id: meta |
| 35 | + run: | |
| 36 | + REPO=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
| 37 | +
|
| 38 | + if [[ "${{ github.event_name }}" == "release" ]]; then |
| 39 | + VERSION_TAG=${{ github.event.release.tag_name }} |
| 40 | + echo "tags<<EOF" >> $GITHUB_OUTPUT |
| 41 | + echo "${REPO}:${VERSION_TAG}" >> $GITHUB_OUTPUT |
| 42 | + echo "${REPO}:latest" >> $GITHUB_OUTPUT |
| 43 | + echo "EOF" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 46 | + PR_NUMBER=${{ github.event.pull_request.number }} |
| 47 | + echo "tags=${REPO}:pr-${PR_NUMBER}" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + else |
| 50 | + echo "tags=${REPO}:dev" >> $GITHUB_OUTPUT |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Build and push multi-platform image |
| 54 | + uses: docker/build-push-action@v6 |
| 55 | + with: |
| 56 | + context: . |
| 57 | + platforms: linux/amd64,linux/arm64 |
| 58 | + push: true |
| 59 | + tags: ${{ steps.meta.outputs.tags }} |
| 60 | + provenance: false |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
0 commit comments