|
1 | | -name: Release (Build & Push Image) |
| 1 | +name: Release Image (GHCR) |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | | - - 'v*' # e.g. v0.1.0 |
7 | | - workflow_dispatch: |
| 6 | + - 'v*' |
8 | 7 |
|
9 | 8 | permissions: |
10 | 9 | contents: read |
11 | | - packages: write # required for GHCR |
| 10 | + packages: write |
12 | 11 |
|
13 | 12 | jobs: |
14 | | - ghcr: |
| 13 | + docker: |
15 | 14 | runs-on: ubuntu-latest |
16 | 15 | steps: |
17 | 16 | - uses: actions/checkout@v4 |
| 17 | + - uses: docker/setup-buildx-action@v3 |
18 | 18 |
|
19 | | - - name: Compute image name & tag |
20 | | - id: prep |
21 | | - run: | |
22 | | - REPO_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') |
23 | | - echo "repo_lc=$REPO_LC" >> $GITHUB_OUTPUT |
24 | | - TAG="${{ github.ref_name }}" |
25 | | - echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 19 | + # GHCR needs lowercase owner (your account is KyleSDeveloper) |
| 20 | + - name: Lowercase owner |
| 21 | + run: echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV |
26 | 22 |
|
27 | 23 | - name: Login to GHCR |
28 | 24 | uses: docker/login-action@v3 |
29 | 25 | with: |
30 | 26 | registry: ghcr.io |
31 | | - username: ${{ github.actor }} |
| 27 | + username: ${{ env.OWNER_LC }} |
32 | 28 | password: ${{ secrets.GITHUB_TOKEN }} |
33 | 29 |
|
34 | | - - name: Set up Buildx |
35 | | - uses: docker/setup-buildx-action@v3 |
36 | | - |
37 | | - - name: Build & Push (GHCR) |
38 | | - uses: docker/build-push-action@v6 |
39 | | - with: |
40 | | - context: . |
41 | | - push: true |
42 | | - tags: | |
43 | | - ghcr.io/${{ steps.prep.outputs.repo_lc }}:${{ steps.prep.outputs.tag }} |
44 | | - ghcr.io/${{ steps.prep.outputs.repo_lc }}:latest |
45 | | - cache-from: type=gha |
46 | | - cache-to: type=gha,mode=max |
47 | | - |
48 | | - dockerhub: |
49 | | - if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} |
50 | | - runs-on: ubuntu-latest |
51 | | - steps: |
52 | | - - uses: actions/checkout@v4 |
53 | | - |
54 | | - - name: Prep tag |
55 | | - id: prep |
56 | | - run: echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT |
57 | | - |
58 | | - - name: Login to Docker Hub |
59 | | - uses: docker/login-action@v3 |
60 | | - with: |
61 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
62 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
63 | | - |
64 | | - - name: Build & Push (Docker Hub) |
65 | | - uses: docker/build-push-action@v6 |
| 30 | + - name: Build & push |
| 31 | + uses: docker/build-push-action@v5 |
66 | 32 | with: |
67 | 33 | context: . |
68 | 34 | push: true |
69 | 35 | tags: | |
70 | | - ${{ secrets.DOCKERHUB_USERNAME }}/serving-app:${{ steps.prep.outputs.tag }} |
71 | | - ${{ secrets.DOCKERHUB_USERNAME }}/serving-app:latest |
72 | | - cache-from: type=gha |
73 | | - cache-to: type=gha,mode=max |
| 36 | + ghcr.io/${{ env.OWNER_LC }}/serving_app:${{ github.ref_name }} |
| 37 | + ghcr.io/${{ env.OWNER_LC }}/serving_app:latest |
0 commit comments