-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (62 loc) · 2.1 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build USFM Scanner Docker Image
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
#build and publish image
Build-Image:
name: Build image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Build image with buildx
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
Push-Image:
name: Push images if this is a branch
runs-on: ubuntu-latest
needs: [Build-Image]
if: ${{ contains(fromJson('["push"]'), github.event_name) }}
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/[email protected]
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Load secret
uses: 1password/load-secrets-action@v1
with:
# Export loaded secrets as environment variables
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
DOCKER_HUB_USER: "op://DevOps/dockerhub-adminwa-token/username"
DOCKER_HUB_TOKEN: "op://DevOps/dockerhub-adminwa-token/credential"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ env.DOCKER_HUB_TOKEN }}
- name: Set docker tags
run: |
echo "TAG_SHA=wycliffeassociates/usfm-scanner:$GITHUB_SHA" >> $GITHUB_ENV && \
echo "TAG_BRANCH=wycliffeassociates/usfm-scanner:$CI_REF_NAME_SLUG" >> $GITHUB_ENV && \
echo "TAG_LATEST=wycliffeassociates/usfm-scanner:latest" >> $GITHUB_ENV
- name: Build and conditional push API image
uses: docker/build-push-action@v3
with:
push: true
tags: |
${{ env.TAG_SHA }}
${{ env.TAG_BRANCH }}
${{ env.TAG_LATEST }}
cache-from: type=gha
cache-to: type=gha,mode=max