-
Notifications
You must be signed in to change notification settings - Fork 11
86 lines (71 loc) · 2.31 KB
/
main.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
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
name: Main
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]
concurrency:
# find the branch name for 'pull_request' or on 'push' events
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: Lint and test code
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v25
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint with ruff
working-directory: ct-app
run: |
nix develop -c ruff check . --output-format=github --ignore E501 --target-version=py39
- name: Test with pytest
working-directory: ct-app
run: |
nix develop -c pytest test
image:
name: Build and push container image
timeout-minutes: 10
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Calculate environment variables
shell: sh
run: |
commit_hash="${{ github.event.pull_request.head.sha }}"
if [ -z "${commit_hash}" ]; then
echo "docker_tag=latest" >> $GITHUB_ENV
else
echo "docker_tag=`echo ${commit_hash} | cut -c1-7`" >> $GITHUB_ENV
fi
- name: Set up Google Cloud Credentials
id: auth
uses: google-github-actions/auth@v2
with:
token_format: "access_token"
credentials_json: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: hoprassociation
install_components: beta
- name: Login Google Container Registry
uses: docker/login-action@v3
with:
registry: europe-west3-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Build container image
uses: docker/build-push-action@v5
with:
push: true
context: ct-app
tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/cover-traffic:${{ env.docker_tag }}