-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (64 loc) · 2.55 KB
/
publish.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
name: Publish
on:
workflow_dispatch:
push:
tags:
- v*
jobs:
publish:
runs-on: ubuntu-latest
env:
DOMAIN_NAME: schedule.lemmings.world
DOMAIN_ZONE: Z04564103VF7YTIMBHJE4
AWS_REGION: eu-central-1
APP_ENV: prod
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FILE_UPLOADER_CLASS: App\FileUploader\S3FileUploader
IMGUR_ACCESS_TOKEN: ${{ secrets.IMGUR_ACCESS_TOKEN }}
UNREAD_POSTS_BOT_JWT: ${{ secrets.UNREAD_POSTS_BOT_JWT }}
CATBOX_USER_HASH: ${{ secrets.CATBOX_USER_HASH }}
UNREAD_POSTS_BOT_INSTANCE: lemmings.world
NEW_VERSION_CHECK: 0
steps:
- name: Extract Version Name
id: extract_version
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (context.payload.ref.startsWith('refs/tags/')) {
return context.payload.ref.replace(/refs\/tags\/v/, '');
}
return 'dev';
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Install serverless
run: yarn global add serverless@3
- name: Checkout code
uses: actions/checkout@v3
- name: Setup php dependencies
run: composer install --no-dev --no-scripts
- name: Setup js dependencies
run: yarn install
- name: Create version file
run: 'echo -e "parameters:\n app.current_version: $VERSION" > config/packages/version.yaml'
env:
VERSION: ${{ steps.extract_version.outputs.result }}
- name: Build assets
run: yarn build
- name: Prepare cache
run: ./bin/console cache:warmup --env=prod
- name: Deploy infrastructure
run: serverless deploy --stage prod --verbose --region $AWS_REGION
- name: Deploy assets
run: |
export ASSETS_BUCKET=$(aws cloudformation describe-stacks --stack-name LemmySchedule-prod --query "Stacks[0].Outputs[?OutputKey=='AssetsBucket'].OutputValue" --output=text --region $AWS_REGION)
aws s3 sync public/build s3://$ASSETS_BUCKET/build --delete
aws s3 sync public/icon s3://$ASSETS_BUCKET/icon --delete
- name: Clear CDN cache
run: |
export CDN_ID=$(aws cloudformation describe-stacks --stack-name LemmySchedule-prod --query "Stacks[0].Outputs[?OutputKey=='Cdn'].OutputValue" --output=text --region $AWS_REGION)
aws cloudfront create-invalidation --distribution-id $CDN_ID --paths "/*" 2>&1 > /dev/null