File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : ghcr.io image
2+
3+ on :
4+ push :
5+ # Publish `main` as Docker `latest` image.
6+ branches :
7+ - main
8+
9+ # Publish `v1.2.3` tags as releases.
10+ tags :
11+ - v*
12+
13+ env :
14+ IMAGE_NAME : commit-check
15+
16+ jobs :
17+ # Push image to GitHub Packages.
18+ # See also https://docs.docker.com/docker-hub/builds/
19+ push :
20+ runs-on : ubuntu-latest
21+ permissions :
22+ packages : write
23+ contents : read
24+
25+ steps :
26+ - uses : actions/checkout@v2
27+
28+ - name : Build image
29+ run : docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
30+
31+ - name : Log in to registry
32+ # This is where you will update the PAT to GITHUB_TOKEN
33+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
34+
35+ - name : Push image
36+ run : |
37+ IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
38+
39+ # Change all uppercase to lowercase
40+ IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
41+ # Strip git ref prefix from version
42+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
43+ # Strip "v" prefix from tag name
44+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
45+ # Use Docker `latest` tag convention
46+ [ "$VERSION" == "main" ] && VERSION=latest
47+ echo IMAGE_ID=$IMAGE_ID
48+ echo VERSION=$VERSION
49+ docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
50+ docker push $IMAGE_ID:$VERSION
You can’t perform that action at this time.
0 commit comments