-
Notifications
You must be signed in to change notification settings - Fork 11
70 lines (57 loc) · 1.91 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
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: echo "SHORT_SHA=`echo ${{ github.event.pull_request.head.sha }} | cut -c1-7`" >> $GITHUB_ENV
- name: Login to GCP
id: gcloud
uses: elgohr/gcloud-login-action@v1 #TODO - v2 is bugged, unable to get outputs
with:
account_key: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Build and push container image
uses: elgohr/Publish-Docker-Github-Action@v5
with:
workdir: "ct-app"
dockerfile: "./Dockerfile"
name: ${{ secrets.GOOGLE_PROJECT }}/${{ secrets.GOOGLE_REPOSITORY }}/cover-traffic
registry: ${{ secrets.GOOGLE_REGION }}-docker.pkg.dev
username: ${{ steps.gcloud.outputs.username }}
password: ${{ steps.gcloud.outputs.password }}
tags: "${{ env.SHORT_SHA }}"