|
11 | 11 | - completed
|
12 | 12 |
|
13 | 13 | jobs:
|
14 |
| - build: |
| 14 | + deploy: |
15 | 15 | runs-on: ubuntu-latest
|
16 |
| - |
| 16 | + outputs: |
| 17 | + release-outputs: ${{ steps.release.outputs }} |
17 | 18 | steps:
|
18 | 19 | - name: Checkout
|
19 |
| - uses: actions/checkout@v2 |
20 |
| - - name: Install, build, and run tests |
21 |
| - id: npm_ci |
22 |
| - run: | |
23 |
| - npm ci |
| 20 | + uses: actions/checkout@v3 |
24 | 21 |
|
25 |
| - # Run release |
26 |
| - - name: semantic-release [DRY-RUN] |
| 22 | + - name: Semantic Release [PUBLISH] |
| 23 | + uses: ./.github/actions/semantic |
| 24 | + id: release |
27 | 25 | env:
|
28 | 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
29 | 27 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
30 |
| - id: release |
31 |
| - run: | |
32 |
| - echo "lastRelease=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT |
33 |
| -
|
34 |
| - npx semantic-release | tee release.output; |
35 |
| -
|
36 |
| - echo "hasRelease=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT |
37 |
| - echo "nextRelease=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT |
38 |
| -
|
39 |
| - - name: Update job summary after semantic-release |
40 |
| - run: | |
41 |
| - if [ '${{ steps.release.outputs.hasRelease }}' == 'true' ]; then |
42 |
| - echo - A new release was be published! >> $GITHUB_STEP_SUMMARY |
43 |
| - echo - Last Release: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY |
44 |
| - echo - Next Release: **${{ steps.release.outputs.nextRelease }}** >> $GITHUB_STEP_SUMMARY |
45 |
| - else |
46 |
| - echo - No release was published! The current release is: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY |
47 |
| - fi |
| 28 | + with: |
| 29 | + publish: true |
| 30 | + add-summary: true |
48 | 31 |
|
49 | 32 | - name: Set up Docker Buildx
|
50 |
| - if: steps.release.outputs.hasRelease == 'true' |
| 33 | + if: steps.release.outputs.new_release_published == 'true' |
51 | 34 | id: buildx
|
52 |
| - uses: docker/setup-buildx-action@master |
| 35 | + uses: docker/setup-buildx-action@v2 |
| 36 | + |
53 | 37 | - name: Cache Docker layers
|
54 |
| - if: steps.release.outputs.hasRelease == 'true' |
| 38 | + if: steps.release.outputs.new_release_published == 'true' |
55 | 39 | uses: actions/cache@v2
|
56 | 40 | with:
|
57 | 41 | path: /tmp/.buildx-cache
|
58 | 42 | key: ${{ runner.os }}-buildx-${{ github.sha }}
|
59 | 43 | restore-keys: |
|
60 | 44 | ${{ runner.os }}-buildx-
|
| 45 | +
|
61 | 46 | - name: Login to Docker Hub
|
62 |
| - if: steps.release.outputs.hasRelease == 'true' |
63 |
| - uses: docker/login-action@v1 |
| 47 | + if: steps.release.outputs.new_release_published == 'true' |
| 48 | + uses: docker/login-action@v2 |
64 | 49 | with:
|
65 | 50 | username: ${{ secrets.DOCKER_USERNAME }}
|
66 | 51 | password: ${{ secrets.DOCKER_PASSWORD }}
|
| 52 | + |
67 | 53 | - name: Docker Build and Push
|
68 |
| - if: steps.release.outputs.hasRelease == 'true' |
| 54 | + if: steps.release.outputs.new_release_published == 'true' |
69 | 55 | id: docker_build
|
70 |
| - uses: docker/build-push-action@v2 |
| 56 | + uses: docker/build-push-action@v4 |
71 | 57 | with:
|
72 |
| - context: . |
73 |
| - file: ./Dockerfile |
74 | 58 | builder: ${{ steps.buildx.outputs.name }}
|
75 | 59 | push: true
|
76 | 60 | tags: |
|
77 | 61 | godaddy/timings:latest
|
78 |
| - godaddy/timings:${{ steps.release.outputs.nextRelease }} |
| 62 | + godaddy/timings:${{ steps.release.outputs.new_release_version }} |
79 | 63 | cache-from: type=local,src=/tmp/.buildx-cache
|
80 | 64 | cache-to: type=local,dest=/tmp/.buildx-cache
|
| 65 | + |
81 | 66 | - name: Image digest
|
82 |
| - run: echo ${{ steps.docker_build.outputs.digest }} |
| 67 | + run: | |
| 68 | + echo ${{ steps.docker_build.outputs.digest }} |
| 69 | + echo Docker image was published sucessfully! >> $GITHUB_STEP_SUMMARY |
| 70 | + echo - Image ID: **${{ steps.docker_build.outputs.imageid }}** >> $GITHUB_STEP_SUMMARY |
| 71 | + echo - digest: **${{ steps.docker_build.outputs.digest }}** >> $GITHUB_STEP_SUMMARY |
| 72 | + echo - metadata: **${{ steps.docker_build.outputs.metadata }}** >> $GITHUB_STEP_SUMMARY |
0 commit comments