-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (104 loc) · 3.95 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: GitHub Actions
on: [ push ]
concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR
env:
# Test image, must be same in the docker-compose.yml if used
APP_IMAGE: keboola/db-extractor-mysql
# Developer portal login
KBC_DEVELOPERPORTAL_VENDOR: "keboola"
KBC_DEVELOPERPORTAL_APP: "keboola.ex-db-mysql"
KBC_DEVELOPERPORTAL_USERNAME: "keboola+github_actions_db_extractor_mysql"
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}
# DockerHub login
DOCKERHUB_USER: "keboolabot"
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# Test KBC project
KBC_STORAGE_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }}
KBC_TEST_PROJECT_URL: "https://connection.keboola.com/admin/projects/2703/dashboard"
KBC_TEST_PROJECT_CONFIGS: "287537333 287589303 288410371 313935368" # space separated list
jobs:
build:
runs-on: ubuntu-latest
outputs:
app_image_tag: ${{ steps.tag.outputs.app_image_tag }}
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Print Docker version
run: |
docker -v
- name: Docker login
if: env.DOCKERHUB_TOKEN
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
- name: Build image
run: docker build -t $APP_IMAGE .
- name: Set image tag
id: tag
run: |
TAG="${GITHUB_REF##*/}"
IS_SEMANTIC_TAG=$(echo "$TAG" | grep -q '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo true || echo false)
echo "Tag = '$TAG', is semantic tag = '$IS_SEMANTIC_TAG'"
echo "is_semantic_tag=$IS_SEMANTIC_TAG" >> $GITHUB_OUTPUT
echo "app_image_tag=$TAG" >> $GITHUB_OUTPUT
- name: Push image to ECR
uses: keboola/action-push-to-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ steps.tag.outputs.app_image_tag }}
push_latest: ${{ steps.tag.outputs.is_semantic_tag }}
source_image: ${{ env.APP_IMAGE}}
tests:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mysql: [ 8, 5.6 ]
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
- name: Run tests
run: |
export MYSQL_VERSION="${{ matrix.mysql }}"
docker compose run app
tests-in-kbc:
needs: build
runs-on: ubuntu-latest
steps:
- name: Run KBC test jobs
uses: keboola/action-run-configs-parallel@master
with:
token: ${{ env.KBC_STORAGE_TOKEN }}
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }}
tag: ${{ needs.build.outputs.app_image_tag }}
configs: ${{ env.KBC_TEST_PROJECT_CONFIGS }}
deploy:
needs:
- build
- tests
- tests-in-kbc
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && needs.build.outputs.is_semantic_tag == 'true'
steps:
- name: Set tag in the Deloper Portal
uses: keboola/action-set-tag-developer-portal@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}