Skip to content

Commit 3afec50

Browse files
authored
Improve deploy workflow structure (#4294)
1 parent 4dcbc89 commit 3afec50

15 files changed

+429
-220
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ indent_size = 2
3030
[Makefile]
3131
indent_style = tab
3232

33-
[*.tf]
33+
[{*.tf,*.tofu}]
3434
indent_size = 2

.github/workflows/build-backend.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
githash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: [self-hosted]
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.ref }}
16+
fetch-depth: 0
17+
- name: Configure AWS credentials
18+
uses: aws-actions/configure-aws-credentials@v4
19+
with:
20+
aws-access-key-id: ${{ secrets.aws_access_key_id }}
21+
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
22+
aws-region: eu-central-1
23+
- name: Set up QEMU dependency
24+
uses: docker/setup-qemu-action@v3
25+
- name: Login to Amazon ECR
26+
uses: aws-actions/amazon-ecr-login@v2
27+
- name: Set up Docker Buildx
28+
id: buildx
29+
uses: docker/setup-buildx-action@v3
30+
- name: Build and push
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: ./backend
34+
file: ./backend/Dockerfile
35+
builder: ${{ steps.buildx.outputs.name }}
36+
provenance: false
37+
push: true
38+
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ inputs.githash }}
39+
cache-from: type=local,src=/tmp/.buildx-cache
40+
cache-to: type=local,dest=/tmp/.buildx-cache
41+
platforms: linux/arm64

.github/workflows/build-base-pretix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
builder: ${{ steps.buildx.outputs.name }}
4040
provenance: false
4141
push: true
42-
tags: ghcr.io/pythonitalia/pycon/arm-pretix:${{ inputs.version }}
42+
tags: ghcr.io/pythonitalia/pycon/base-pretix:${{ inputs.version }}
4343
cache-from: type=local,src=/tmp/.buildx-cache
4444
cache-to: type=local,dest=/tmp/.buildx-cache
4545
platforms: linux/arm64

.github/workflows/build-frontend.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
githash:
5+
required: true
6+
type: string
7+
tf_environment:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: [self-hosted]
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.ref }}
19+
fetch-depth: 0
20+
- name: Configure AWS credentials
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
aws-access-key-id: ${{ secrets.aws_access_key_id }}
24+
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
25+
aws-region: eu-central-1
26+
- name: Set up QEMU dependency
27+
uses: docker/setup-qemu-action@v3
28+
- name: Login to Amazon ECR
29+
uses: aws-actions/amazon-ecr-login@v2
30+
- name: Set up Docker Buildx
31+
id: buildx
32+
uses: docker/setup-buildx-action@v3
33+
- name: Get vars
34+
id: vars
35+
run: |
36+
cms_hostname=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ inputs.tf_environment }}/pycon-frontend/cms-hostname)
37+
echo "CMS_HOSTNAME=$cms_hostname" >> "$GITHUB_OUTPUT"
38+
39+
conference_code=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ inputs.tf_environment }}/pycon-frontend/conference-code)
40+
echo "CONFERENCE_CODE=$conference_code" >> "$GITHUB_OUTPUT"
41+
42+
sentry_auth_token=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ inputs.tf_environment }}/common/sentry-auth-token)
43+
echo "::add-mask::$sentry_auth_token"
44+
echo "SENTRY_AUTH_TOKEN=$sentry_auth_token" >> "$GITHUB_OUTPUT"
45+
- name: Build and push
46+
uses: docker/build-push-action@v6
47+
with:
48+
context: ./frontend
49+
file: ./frontend/Dockerfile
50+
builder: ${{ steps.buildx.outputs.name }}
51+
provenance: false
52+
push: true
53+
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/${{ inputs.tf_environment }}-pycon-frontend:${{ inputs.githash }}
54+
cache-from: type=local,src=/tmp/.buildx-cache
55+
cache-to: type=local,dest=/tmp/.buildx-cache
56+
platforms: linux/arm64
57+
build-args: |
58+
API_URL_SERVER=https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
59+
NEXT_PUBLIC_SITE_URL=${{ fromJSON('["pastaporto-frontend.", ""]')[github.ref == 'refs/heads/main'] }}pycon.it
60+
CMS_ADMIN_HOST=${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
61+
CMS_HOSTNAME=${{ steps.vars.outputs.cms_hostname }}
62+
CONFERENCE_CODE=${{ steps.vars.outputs.conference_code }}
63+
GIT_HASH=${{ inputs.githash }}
64+
secrets: |
65+
"sentry_auth_token=${{ steps.vars.outputs.sentry_auth_token }}"

.github/workflows/build-pretix.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
githash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build:
10+
name: Build pretix
11+
runs-on: [self-hosted]
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.ref }}
16+
fetch-depth: 0
17+
- name: Configure AWS credentials
18+
uses: aws-actions/configure-aws-credentials@v4
19+
with:
20+
aws-access-key-id: ${{ secrets.aws_access_key_id }}
21+
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
22+
aws-region: eu-central-1
23+
- name: Login to Amazon ECR
24+
uses: aws-actions/amazon-ecr-login@v2
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v3
28+
- name: Build and push pretix
29+
uses: docker/build-push-action@v6
30+
with:
31+
context: ./pretix
32+
file: ./pretix/Dockerfile
33+
builder: ${{ steps.buildx.outputs.name }}
34+
provenance: false
35+
push: true
36+
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pretix:arm-${{ inputs.githash }}
37+
cache-from: type=local,src=/tmp/.buildx-cache
38+
cache-to: type=local,dest=/tmp/.buildx-cache
39+
platforms: linux/arm64

0 commit comments

Comments
 (0)