Skip to content

Commit 8638c4c

Browse files
.
1 parent 3411528 commit 8638c4c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

.github/workflows/build.yaml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
# steps:
1212
# - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
1313
# - uses: actions/checkout@v2
14-
# - run: npm install -g @devcontainers/[email protected]
1514
# - run: |
1615
# set -e -x -u -o pipefail
1716
# repo=ghcr.io/treebeardtech/dev-images; tag=latest
@@ -55,17 +54,24 @@ jobs:
5554
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
5655
with:
5756
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
6975
7076
# 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)."
7177
- name: Generate artifact attestation

0 commit comments

Comments
 (0)