-
Notifications
You must be signed in to change notification settings - Fork 8
65 lines (56 loc) · 2.09 KB
/
dockerimage.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
name: Docker Image CI
on:
push:
branches: [ master, prod ]
pull_request:
branches: [ master, prod ]
env:
RC_NAME: davidtnfsh/pycon_etl
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to docker hub
uses: actions-hub/docker/login@master
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull cache
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull ${RC_NAME}:cache
- name: Build the Docker image
if: always()
run: |
docker build -t ${RC_NAME}:${GITHUB_SHA} --cache-from ${RC_NAME}:cache .
docker tag ${RC_NAME}:${GITHUB_SHA} ${RC_NAME}:cache
docker build -t ${RC_NAME}:test --cache-from ${RC_NAME}:cache -f Dockerfile.test .
docker tag ${RC_NAME}:${GITHUB_SHA} ${RC_NAME}:staging
docker tag ${RC_NAME}:${GITHUB_SHA} ${RC_NAME}:latest
- name: Run test
run: |
docker run -d --rm -p 8080:8080 --name airflow -v $(pwd)/dags:/usr/local/airflow/dags -v $(pwd)/fixtures:/usr/local/airflow/fixtures ${RC_NAME}:test webserver
sleep 10
docker exec airflow bash -c "airflow test OPENING_CRAWLER_V1 CRAWLER 2020-01-01"
docker exec airflow bash -c "airflow test QUESTIONNAIRE_2_BIGQUERY TRANSFORM_data_questionnaire 2020-09-29"
- name: Push Cache to docker registry
uses: actions-hub/docker@master
if: always()
with:
args: push ${RC_NAME}:cache
- name: Push GITHUB_SHA to docker registry
uses: actions-hub/docker@master
if: always()
with:
args: push ${RC_NAME}:${GITHUB_SHA}
- name: Push staging to docker registry
uses: actions-hub/docker@master
if: github.ref == 'refs/heads/master' && success()
with:
args: push ${RC_NAME}:staging
- name: Push prod version to docker registry
uses: actions-hub/docker@master
if: github.ref == 'refs/heads/prod' && success()
with:
args: push ${RC_NAME}:latest