Skip to content

Commit 5c13187

Browse files
committed
split
1 parent 6646e62 commit 5c13187

File tree

4 files changed

+117
-103
lines changed

4 files changed

+117
-103
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
githash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build:
10+
name: Build backend
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: |
39+
${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ inputs.githash }}
40+
cache-from: type=local,src=/tmp/.buildx-cache
41+
cache-to: type=local,dest=/tmp/.buildx-cache
42+
platforms: linux/arm64
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
githash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build:
10+
name: Build frontend
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: Get vars
31+
id: vars
32+
run: |
33+
cms_hostname=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/cms-hostname)
34+
echo "CMS_HOSTNAME=$cms_hostname" >> "$GITHUB_OUTPUT"
35+
36+
conference_code=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/conference-code)
37+
echo "CONFERENCE_CODE=$conference_code" >> "$GITHUB_OUTPUT"
38+
39+
sentry_auth_token=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/common/sentry-auth-token)
40+
echo "::add-mask::$sentry_auth_token"
41+
echo "SENTRY_AUTH_TOKEN=$sentry_auth_token" >> "$GITHUB_OUTPUT"
42+
- name: Build and push
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: ./frontend
46+
file: ./frontend/Dockerfile
47+
builder: ${{ steps.buildx.outputs.name }}
48+
provenance: false
49+
push: true
50+
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}-pycon-frontend:${{ inputs.githash }}
51+
cache-from: type=local,src=/tmp/.buildx-cache
52+
cache-to: type=local,dest=/tmp/.buildx-cache
53+
platforms: linux/arm64
54+
build-args: |
55+
API_URL_SERVER=https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
56+
NEXT_PUBLIC_SITE_URL=${{ fromJSON('["pastaporto-frontend.", ""]')[github.ref == 'refs/heads/main'] }}pycon.it
57+
CMS_ADMIN_HOST=${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
58+
CMS_HOSTNAME=${{ steps.vars.outputs.cms_hostname }}
59+
CONFERENCE_CODE=${{ steps.vars.outputs.conference_code }}
60+
GIT_HASH=${{ inputs.githash }}
61+
secrets: |
62+
"sentry_auth_token=${{ steps.vars.outputs.sentry_auth_token }}"

.github/workflows/build-pretix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-latest
10+
name: Build pretix
11+
runs-on: [self-hosted]
1112
steps:
1213
- uses: actions/checkout@v4
1314
with:

.github/workflows/deploy.yml

Lines changed: 11 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ jobs:
4646
fi
4747
4848
build-pretix:
49-
name: Build pretix
50-
runs-on: [self-hosted]
5149
needs: [check-pretix-build]
52-
if: ${{ needs.check-pretix-build.outputs.image_exists == 0 }}
5350
uses: ./.github/workflows/build-pretix.yml
5451
with:
5552
githash: ${{ needs.check-pretix-build.outputs.githash }}
53+
secrets: inherit
54+
if: ${{ needs.check-pretix-build.outputs.image_exists == 0 }}
5655

5756
check-backend-build:
5857
name: Check backend needs building
@@ -88,37 +87,12 @@ jobs:
8887
fi
8988
9089
build-be:
91-
name: Build backend
92-
runs-on: [self-hosted]
9390
needs: [check-backend-build]
91+
uses: ./.github/workflows/build-backend.yml
92+
with:
93+
githash: ${{ needs.check-backend-build.outputs.githash }}
94+
secrets: inherit
9495
if: ${{ needs.check-backend-build.outputs.image_exists == 0 }}
95-
steps:
96-
- name: Configure AWS credentials
97-
uses: aws-actions/configure-aws-credentials@v4
98-
with:
99-
aws-access-key-id: ${{ secrets.aws_access_key_id }}
100-
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
101-
aws-region: eu-central-1
102-
- name: Set up QEMU dependency
103-
uses: docker/setup-qemu-action@v3
104-
- name: Login to Amazon ECR
105-
uses: aws-actions/amazon-ecr-login@v2
106-
- name: Set up Docker Buildx
107-
id: buildx
108-
uses: docker/setup-buildx-action@v3
109-
- name: Build and push
110-
uses: docker/build-push-action@v6
111-
with:
112-
context: ./backend
113-
file: ./backend/Dockerfile
114-
builder: ${{ steps.buildx.outputs.name }}
115-
provenance: false
116-
push: true
117-
tags: |
118-
${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ needs.check-backend-build.outputs.githash }}
119-
cache-from: type=local,src=/tmp/.buildx-cache
120-
cache-to: type=local,dest=/tmp/.buildx-cache
121-
platforms: linux/arm64
12296

12397
deploy-be:
12498
name: Deploy backend
@@ -203,76 +177,12 @@ jobs:
203177
fi
204178
205179
build-fe:
206-
name: Build frontend
207-
needs: [wait-be-update, check-frontend-build]
208-
runs-on: [self-hosted]
180+
needs: [check-frontend-build]
181+
uses: ./.github/workflows/build-frontend.yml
182+
with:
183+
githash: ${{ needs.check-frontend-build.outputs.githash }}
184+
secrets: inherit
209185
if: ${{ needs.check-frontend-build.outputs.image_exists == 0 }}
210-
steps:
211-
- uses: actions/checkout@v4
212-
with:
213-
ref: ${{ github.ref }}
214-
fetch-depth: 0
215-
- name: Configure AWS credentials
216-
uses: aws-actions/configure-aws-credentials@v4
217-
with:
218-
aws-access-key-id: ${{ secrets.aws_access_key_id }}
219-
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
220-
aws-region: eu-central-1
221-
- name: Get service githash
222-
id: git
223-
run: |
224-
hash=$(git rev-list -1 HEAD -- frontend)
225-
echo "githash=$hash" >> $GITHUB_OUTPUT
226-
- name: Check if commit is already on ECR
227-
id: image
228-
run: |
229-
set +e
230-
aws ecr describe-images --repository-name=pythonit/${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}-pycon-frontend --image-ids=imageTag=${{ steps.git.outputs.githash }}
231-
if [[ $? == 0 ]]; then
232-
echo "image_exists=1" >> $GITHUB_OUTPUT
233-
else
234-
echo "image_exists=0" >> $GITHUB_OUTPUT
235-
fi
236-
- name: Set up QEMU dependency
237-
uses: docker/setup-qemu-action@v3
238-
- name: Login to Amazon ECR
239-
uses: aws-actions/amazon-ecr-login@v2
240-
- name: Set up Docker Buildx
241-
id: buildx
242-
uses: docker/setup-buildx-action@v3
243-
- name: Get vars
244-
id: vars
245-
run: |
246-
cms_hostname=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/cms-hostname)
247-
echo "CMS_HOSTNAME=$cms_hostname" >> "$GITHUB_OUTPUT"
248-
249-
conference_code=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/pycon-frontend/conference-code)
250-
echo "CONFERENCE_CODE=$conference_code" >> "$GITHUB_OUTPUT"
251-
252-
sentry_auth_token=$(aws ssm get-parameter --output text --query Parameter.Value --with-decryption --name /pythonit/${{ env.TF_WORKSPACE }}/common/sentry-auth-token)
253-
echo "::add-mask::$sentry_auth_token"
254-
echo "SENTRY_AUTH_TOKEN=$sentry_auth_token" >> "$GITHUB_OUTPUT"
255-
- name: Build and push
256-
uses: docker/build-push-action@v6
257-
with:
258-
context: ./frontend
259-
file: ./frontend/Dockerfile
260-
builder: ${{ steps.buildx.outputs.name }}
261-
provenance: false
262-
push: true
263-
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}-pycon-frontend:${{ steps.git.outputs.githash }}
264-
cache-from: type=local,src=/tmp/.buildx-cache
265-
cache-to: type=local,dest=/tmp/.buildx-cache
266-
platforms: linux/arm64
267-
build-args: |
268-
API_URL_SERVER=https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
269-
NEXT_PUBLIC_SITE_URL=${{ fromJSON('["pastaporto-frontend.", ""]')[github.ref == 'refs/heads/main'] }}pycon.it
270-
CMS_ADMIN_HOST=${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it
271-
CMS_HOSTNAME=${{ steps.vars.outputs.cms_hostname }}
272-
CONFERENCE_CODE=${{ steps.vars.outputs.conference_code }}
273-
GIT_HASH=${{ steps.git.outputs.githash }}
274-
secrets: |
275-
"sentry_auth_token=${{ steps.vars.outputs.sentry_auth_token }}"
276186

277187
deploy-fe:
278188
name: Deploy frontend
@@ -300,7 +210,6 @@ jobs:
300210
- name: Terraform Validate
301211
id: validate
302212
run: terraform validate -no-color
303-
304213
- name: Terraform apply
305214
run: terraform apply -no-color -auto-approve &> /dev/null
306215
env:

0 commit comments

Comments
 (0)