This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (142 loc) · 5.45 KB
/
cicd-pipeline.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: CI/CD Pipeline
on: push
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_REGISTRY: ghcr.io
ERICA_HOST: ${{ secrets.ERICA_HOST_STAGING }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install build requirements
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.build.txt
shell: bash
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-erica-v${{ secrets.CACHE_VERSION }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
- name: Install dependencies
env:
SETUPTOOLS_USE_DISTUTILS: stdlib
run: |
pipenv install --dev
shell: bash
- name: Get Eric binaries
env:
ERICA_BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
run: |
pipenv run python scripts/load_eric_binaries.py download-eric-cert-and-binaries
- name: Update tax office list
env:
ERICA_ENV: testing
run: |
pipenv run python scripts/create_tax_office_lists.py create
- name: Lint
run: |
pipenv run invoke --echo lint
shell: bash
- name: Test
run: |
pipenv run invoke --echo test | tee erica-test-report.log
shell: bash
- name: Archive test logs
uses: actions/upload-artifact@v1
with:
name: erica-test-report.log
path: erica-test-report.log
build-staging:
needs: [test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Build docker images
env:
DOCKER_REGISTRY: ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}
DOCKER_TAG: ${{ github.run_number }}
ERICA_BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
ELSTER_DATENLIEFERANT: ${{ secrets.ELSTER_DATENLIEFERANT }}
ELSTER_HERSTELLER_ID: ${{ secrets.ELSTER_HERSTELLER_ID }}
run: |
docker-compose -f docker-compose.ci.yml build
docker image ls
shell: bash
- name: Create SBOM
uses: digitalservicebund/github-actions/create-sbom@40022b2843c5d9f9efba2c92d9421e19d3a1a3de
with:
repository: ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}
image_tag: erica_main:latest
- name: Login to container repository
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
run: |
for IMAGE in $(docker image ls | grep erica_ | awk '{ print $1 }' | sort | uniq); do
docker push ${IMAGE} --all-tags
done
shell: bash
- name: Install cosign
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65
- name: Sign the published Docker image
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: |
for IMAGE in $(docker image ls | grep erica_ | awk '{ print $1 }' | sort | uniq); do
cosign sign ${IMAGE}:${{ github.run_number }} --yes
done
shell: bash
deploy-staging-otc:
needs: [build-staging]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: ./.github/workflows/reusable-deploy-otc.yml
with:
imageTag: ${{ github.run_number }}
environment: staging
secrets:
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PWD: ${{ secrets.REGISTRY_PWD_GITHUB }}
ERICA_SSH_KEY: ${{ secrets.CI_ERICA_SSH_KEY }}
ERICA_HOST: ${{ secrets.ERICA_HOST_OTC_STAGING }}
CERT_PIN: ${{ secrets.CERT_PIN_OTC_STAGING }}
QUEUE_URL: ${{ secrets.QUEUE_URL_OTC_STAGING }}
ERICA_DATABASE_URL: ${{ secrets.ERICA_DATABASE_URL_OTC_STAGING }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
ARGOCD_SERVER: ${{ secrets.ARGOCD_SERVER }}
ARGOCD_PIPELINE_PASSWORD: ${{ secrets.ARGOCD_PIPELINE_PASSWORD }}
track-deploy:
needs: [deploy-staging-otc]
runs-on: ubuntu-latest
steps:
- name: Track deploy
uses: digitalservicebund/github-actions/track-deployment@34a48d29a9c4cc2fd6710b8eb37e13618a08fa88
with:
project: Erica
environment: staging
metrics_deployment_webhook_url: ${{ secrets.METRICS_DEPLOYMENT_WEBHOOK_URL }}
metrics_webhook_token: ${{ secrets.METRICS_WEBHOOK_TOKEN }}