-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (34 loc) · 1.13 KB
/
push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Push
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/build-container
on:
push:
schedule:
- cron: 30 3 * * SUN
jobs:
test-docker:
name: Docker Build
runs-on: ubuntu-latest
container:
image: docker:latest
steps:
- uses: actions/checkout@v3
- run: docker pull $IMAGE_NAME:latest || true
- run: docker build --cache-from $IMAGE_NAME:latest .
deploy-build-and-push-image:
name: Build and Push Image
if: github.ref == 'refs/heads/master'
needs: [test-docker]
runs-on: ubuntu-latest
container:
image: docker:latest
env:
GHCR_BOT_USERNAME: ${{ secrets.GHCR_BOT_USERNAME }}
GHCR_BOT_TOKEN: ${{ secrets.GHCR_BOT_TOKEN }}
steps:
- uses: actions/checkout@v3
- run: echo "${GHCR_BOT_TOKEN}" | docker login ghcr.io -u ${GHCR_BOT_USERNAME} --password-stdin
- run: docker pull $IMAGE_NAME:latest || true
- run: docker build --cache-from ${IMAGE_NAME}:latest --tag ${IMAGE_NAME}:${{ github.sha }} --tag ${IMAGE_NAME}:latest .
- run: docker push ${IMAGE_NAME}:${{ github.sha }}
- run: docker push ${IMAGE_NAME}:latest