generated from centrefornetzero/python-template
-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (56 loc) · 2.8 KB
/
container.yaml
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
name: Containers
on: [push]
env:
ARTIFACT_REGISTRY: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
jobs:
build-test-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: google-github-actions/setup-gcloud@v0.2.0
with:
service_account_key: ${{ secrets.GCP_ARTIFACT_REGISTRY_SA_KEY }}
- run: gcloud auth configure-docker "$(echo "$ARTIFACT_REGISTRY" | awk -F/ '{print $1}')"
- run: docker buildx install
- name: Build images
run: |
docker build . --target runtime \
-t "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA" \
--cache-from "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":latest \
--build-arg BUILDKIT_INLINE_CACHE=1
docker build . --target testrunner \
-t "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"-testrunner \
--cache-from "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":latest-testrunner \
--build-arg BUILDKIT_INLINE_CACHE=1
- name: Run pytest
run: docker run "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"-testrunner pytest
- name: Check formatting
run: docker run "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"-testrunner ./scripts/format_check.sh
- name: Push images
run: |
docker push "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"
docker push "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"-testrunner
- name: Tag latest images
if: ${{ github.ref == 'refs/heads/main' }}
run: |
gcloud artifacts docker tags add "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA" \
"$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":latest
gcloud artifacts docker tags add "$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":"$GITHUB_SHA"-testrunner \
"$ARTIFACT_REGISTRY"/docker/"${GITHUB_REPOSITORY#*/}":latest-testrunner
match-job:
needs: build-test-push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- uses: google-github-actions/setup-gcloud@v0.2.0
with:
service_account_key: ${{ secrets.GCP_GITHUB_ACTION_SA_KEY }}
project_id: ${{ secrets.GCP_DATA_WAREHOUSE_PROJECT_ID }}
- name: Submit job
run: ./scripts/submit_job.sh
env:
GCP_PROJECT_ID: ${{ secrets.GCP_DATA_WAREHOUSE_PROJECT_ID }}
BUCKET_NAME: ${{ secrets.GCP_SCRATCH_BUCKET_NAME }}
SERVICE_ACCOUNT: epc-ppd-matching-runner@${{ secrets.GCP_DATA_WAREHOUSE_PROJECT_ID }}.iam.gserviceaccount.com
IMAGE_URI: ${{ secrets.GCP_ARTIFACT_REGISTRY }}/docker/epc-ppd-address-matching:latest