File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Docker
2+
3+ on :
4+ schedule :
5+ - cron : " 0 0 * * *"
6+ push :
7+ # Publish `main` as Docker `latest` image.
8+ branches :
9+ - main
10+
11+ # Publish `v1.2.3` tags as releases.
12+ tags :
13+ - v*
14+
15+ env :
16+ IMAGE_NAME : default
17+
18+ jobs :
19+ push :
20+
21+ runs-on : ubuntu-latest
22+ if : ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
23+
24+ steps :
25+ - uses : actions/checkout@v2
26+
27+ - name : Build image
28+ run : docker build . --file Dockerfile --tag $IMAGE_NAME --cache-from ghcr.io/${{ github.repository }}:latest
29+
30+ - name : Login to GitHub Container Registry
31+ uses : docker/login-action@v1
32+ with :
33+ registry : ghcr.io
34+ username : ${{ github.actor }}
35+ password : ${{ secrets.GITHUB_TOKEN }}
36+
37+ - name : Push image
38+ run : |
39+ IMAGE_ID=ghcr.io/${{ github.repository }}
40+ # Change all uppercase to lowercase
41+ IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
42+ # Strip git ref prefix from version
43+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
44+ # Strip "v" prefix from tag name
45+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
46+ # Use Docker `latest` tag convention
47+ [ "$VERSION" == "main" ] && VERSION=latest
48+ echo IMAGE_ID=$IMAGE_ID
49+ echo VERSION=$VERSION
50+ docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
51+ docker push $IMAGE_ID:$VERSION
You can’t perform that action at this time.
0 commit comments