-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (41 loc) · 1.43 KB
/
docker-build.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
39
40
41
42
43
on:
workflow_call:
secrets:
GHCR_BOT_USERNAME:
required: true
GHCR_BOT_TOKEN:
required: true
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reaper
AWS_DEFAULT_REGION: us-east-1
jobs:
docker-build:
name: Build Image
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 .
deploy-build-and-push-image:
name: Build and Push Image
if: github.ref == 'refs/heads/master'
needs: [docker-build]
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