|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | build: |
10 | | - runs-on: ubuntu-20.04 |
| 10 | + runs-on: ubuntu-22.04 |
11 | 11 | if: endsWith(github.ref, '/prod') || endsWith(github.ref, '/stage') || endsWith(github.ref, '/migration') |
12 | 12 | steps: |
13 | 13 | - name: Checkout repository |
14 | | - uses: actions/checkout@v2 |
| 14 | + uses: actions/checkout@v4 |
15 | 15 |
|
16 | 16 | - name: Set up Docker Buildx |
17 | | - uses: docker/setup-buildx-action@v1 |
| 17 | + uses: docker/setup-buildx-action@v3 |
18 | 18 |
|
19 | 19 | - name: Login to DockerHub |
20 | | - uses: docker/login-action@v1 |
| 20 | + uses: docker/login-action@v3 |
21 | 21 | with: |
22 | 22 | username: ${{ secrets.DOCKER_USERNAME }} |
23 | 23 | password: ${{ secrets.DOCKER_PASSWORD }} |
24 | 24 |
|
25 | | - - name: Build and push production image |
26 | | - if: endsWith(github.ref, '/prod') |
27 | | - uses: docker/build-push-action@v2 |
28 | | - with: |
29 | | - context: . |
30 | | - file: ./Dockerfile |
31 | | - tags: ${{ env.DOCKER_REPO }}:prod |
32 | | - push: ${{ endsWith(github.ref, '/prod') }} |
33 | | - |
34 | | - - name: Build and push stage image |
35 | | - if: endsWith(github.ref, '/stage') |
36 | | - uses: docker/build-push-action@v2 |
| 25 | + - name: Extract metadata (tags, labels) for Docker |
| 26 | + id: meta |
| 27 | + uses: docker/metadata-action@v5 |
37 | 28 | with: |
38 | | - context: . |
39 | | - file: ./stage.Dockerfile |
40 | | - tags: ${{ env.DOCKER_REPO }}:stage |
41 | | - push: ${{ endsWith(github.ref, '/stage') }} |
| 29 | + images: ${{ env.DOCKER_REPO }} |
| 30 | + tags: | |
| 31 | + type=ref,event=branch |
| 32 | + type=ref,event=pr |
| 33 | + type=raw,value=latest,enable={{is_default_branch}} |
| 34 | + type=raw,value={{branch}}-{{sha}}-{{date 'X'}},enable=${{ startsWith(github.ref, 'refs/heads') }} |
42 | 35 |
|
43 | | - - name: Build and push migration image |
44 | | - if: endsWith(github.ref, '/migration') |
45 | | - uses: docker/build-push-action@v2 |
| 36 | + - name: Build and push production image |
| 37 | + uses: docker/build-push-action@v5 |
46 | 38 | with: |
47 | 39 | context: . |
48 | | - file: ./stage.Dockerfile |
49 | | - tags: ${{ env.DOCKER_REPO }}:migration |
50 | | - push: ${{ endsWith(github.ref, '/migration') }} |
| 40 | + file: ./Dockerfile |
| 41 | + tags: ${{ steps.meta.outputs.tags }} |
| 42 | + push: true |
0 commit comments