|
3 | 3 | release:
|
4 | 4 | types:
|
5 | 5 | - created
|
| 6 | +env: |
| 7 | + REGISTRY: ghcr.io |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
6 | 9 | jobs:
|
7 | 10 | test-build:
|
8 | 11 | runs-on: ubuntu-latest
|
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
9 | 15 | steps:
|
10 |
| - - uses: actions/checkout@v2 |
11 |
| - - name: Build container (which includes running tests) |
12 |
| - run: docker build . |
13 |
| - - name: Log into registry |
14 |
| - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin |
15 |
| - - name: Push image |
16 |
| - run: | |
17 |
| - IMAGE_ID=docker.pkg.github.com/${{ github.repository }} |
18 |
| - # Strip git ref prefix from version |
19 |
| - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
20 |
| - # Use Docker `latest` tag convention |
21 |
| - [ "$VERSION" == "master" ] && VERSION=latest |
22 |
| - echo IMAGE_ID=$IMAGE_ID |
23 |
| - echo VERSION=$VERSION |
24 |
| - docker tag image $IMAGE_ID:$VERSION |
25 |
| - docker push $IMAGE_ID:$VERSION |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Log in to the Container registry |
| 19 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
| 20 | + with: |
| 21 | + registry: ${{ env.REGISTRY }} |
| 22 | + username: ${{ github.actor }} |
| 23 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - name: Extract metadata (tags, labels) for Docker |
| 26 | + id: meta |
| 27 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 28 | + with: |
| 29 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 30 | + |
| 31 | + - name: Build and push Docker image |
| 32 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
| 33 | + with: |
| 34 | + context: . |
| 35 | + push: true |
| 36 | + tags: ${{ steps.meta.outputs.tags }} |
| 37 | + labels: ${{ steps.meta.outputs.labels }} |
| 38 | + |
26 | 39 | release-notes:
|
27 | 40 | needs: test-build
|
28 | 41 | if: ${{ github.event_name == 'release' }}
|
|
0 commit comments