1+ name : Docker
2+
3+ # This workflow uses actions that are not certified by GitHub.
4+ # They are provided by a third-party and are governed by
5+ # separate terms of service, privacy policy, and support
6+ # documentation.
7+
8+ on :
9+ schedule :
10+ - cron : ' 18 17 * * *'
11+ push :
12+ branches : [ ]
13+ # Publish semver tags as releases.
14+ tags : [ 'v*.*.*' ]
15+ pull_request :
16+ branches : [ ]
17+
18+ env :
19+ # Use docker.io for Docker Hub if empty
20+ REGISTRY : ghcr.io
21+ # github.repository as <account>/<repo>
22+ IMAGE_NAME : ${{ github.repository }}
23+
24+
25+ jobs :
26+ build :
27+
28+ runs-on : ubuntu-latest
29+ permissions :
30+ contents : read
31+ packages : write
32+
33+ steps :
34+ - name : Checkout repository
35+ uses : actions/checkout@v2
36+
37+ # Login against a Docker registry except on PR
38+ # https://github.com/docker/login-action
39+ - name : Log into registry ${{ env.REGISTRY }}
40+ if : github.event_name != 'pull_request'
41+ uses : docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
42+ with :
43+ registry : ${{ env.REGISTRY }}
44+ username : ${{ github.actor }}
45+ password : ${{ secrets.GITHUB_TOKEN }}
46+
47+ # Extract metadata (tags, labels) for Docker
48+ # https://github.com/docker/metadata-action
49+ - name : Extract Docker metadata
50+ id : meta
51+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
52+ with :
53+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
55+ # Build and push Docker image with Buildx (don't push on PR)
56+ # https://github.com/docker/build-push-action
57+ - name : Build and push Docker image
58+ uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
59+ with :
60+ context : .
61+ push : ${{ github.event_name != 'pull_request' }}
62+ tags : ${{ steps.meta.outputs.tags }}
63+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments