|
11 | 11 | # steps: |
12 | 12 | # - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin |
13 | 13 | # - uses: actions/checkout@v2 |
14 | | -# - run: npm install -g @devcontainers/[email protected] |
15 | 14 | # - run: | |
16 | 15 | # set -e -x -u -o pipefail |
17 | 16 | # repo=ghcr.io/treebeardtech/dev-images; tag=latest |
@@ -55,17 +54,24 @@ jobs: |
55 | 54 | uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
56 | 55 | with: |
57 | 56 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
58 | | - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. |
59 | | - # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. |
60 | | - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. |
61 | | - - name: Build and push Docker image |
62 | | - id: push |
63 | | - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
64 | | - with: |
65 | | - context: . |
66 | | - push: true |
67 | | - tags: ${{ steps.meta.outputs.tags }} |
68 | | - labels: ${{ steps.meta.outputs.labels }} |
| 57 | + - name: Build image |
| 58 | + run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" |
| 59 | + - name: Push image |
| 60 | + run: | |
| 61 | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME |
| 62 | +
|
| 63 | + # This changes all uppercase characters to lowercase. |
| 64 | + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') |
| 65 | + # This strips the git ref prefix from the version. |
| 66 | + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
| 67 | + # This strips the "v" prefix from the tag name. |
| 68 | + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') |
| 69 | + # This uses the Docker `latest` tag convention. |
| 70 | + [ "$VERSION" == "main" ] && VERSION=latest |
| 71 | + echo IMAGE_ID=$IMAGE_ID |
| 72 | + echo VERSION=$VERSION |
| 73 | + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION |
| 74 | + docker push $IMAGE_ID:$VERSION |
69 | 75 | |
70 | 76 | # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." |
71 | 77 | - name: Generate artifact attestation |
|
0 commit comments