Skip to content

Commit

Permalink
Merge branch 'master' into feature/design
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Mar 27, 2024
2 parents f4b7b57 + 59f4bc6 commit eaebcad
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/delete-dev-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Delete Dev Version

on:
workflow_dispatch:
pull_request:
types: [closed]

jobs:
delete:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: GitHub Slug Action
uses: rlespinasse/github-slug-action@v4
- name: Generate SLS Stage
id: generate_sls_stage
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (context.payload.ref == 'refs/heads/master') {
return 'prod';
}
return process.env.GITHUB_REF_NAME_SLUG_URL;
- name: Remove Dev Version
env:
STACK_NAME: HordeNG-${{ env.GITHUB_REF_NAME_SLUG_URL }}
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
export BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='Bucket'].OutputValue" --output=text)
export DEPLOYMENT_BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='ServerlessDeploymentBucketName'].OutputValue" --output=text)
aws s3 rm s3://$BUCKET_NAME --recursive
aws s3 rm s3://$DEPLOYMENT_BUCKET_NAME --recursive
aws cloudformation delete-stack --stack-name $STACK_NAME
- name: Post Link
uses: thollander/actions-comment-pull-request@v2
with:
message: The preview URL for this PR was deleted when the PR got closed.
comment_tag: post_link_comment
39 changes: 35 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,57 @@ on:
push:
branches:
- master
pull_request:

jobs:
publish:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: GitHub Slug Action
uses: rlespinasse/github-slug-action@v4
- name: Generate Domain Name
id: generate_domain_name
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (context.payload.ref == 'refs/heads/master') {
return 'horde-ng.org';
}
return process.env.GITHUB_REF_NAME_SLUG_URL + '.dev.horde-ng.org';
- name: Generate SLS Stage
id: generate_sls_stage
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (context.payload.ref == 'refs/heads/master') {
return 'prod';
}
return process.env.GITHUB_REF_NAME_SLUG_URL;
- name: Checkout code
uses: actions/checkout@v4
- name: Setup prod dependencies
run: yarn install
- name: Deploy infrastructure
uses: serverless/github-action@v3
with:
args: deploy --stage prod --verbose
args: deploy --stage ${{ steps.generate_sls_stage.outputs.result }} --verbose
env:
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DOMAIN_ZONE: ${{ secrets.APP_DOMAIN_HOSTED_ZONE }}
DOMAIN_NAME: horde-ng.org
DOMAIN_NAME: ${{ steps.generate_domain_name.outputs.result }}
- name: Create runtime version
run: echo "window['APP_VERSION'] = '$GITHUB_SHA';" >> src/assets/runtime-variables.js
- name: Build app
run: ./node_modules/.bin/ng build
- name: Copy files to S3
env:
STACK_NAME: HordeNG-prod
STACK_NAME: HordeNG-${{ steps.generate_sls_stage.outputs.result }}
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -39,10 +64,16 @@ jobs:
aws s3 sync dist/horde-gui/browser s3://$BUCKET --delete
- name: Create invalidation
env:
STACK_NAME: HordeNG-prod
STACK_NAME: HordeNG-${{ steps.generate_sls_stage.outputs.result }}
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
CDN_ID=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='Cdn'].OutputValue" --output=text)
aws cloudfront create-invalidation --distribution-id $CDN_ID --paths "/*" 2>&1 > /dev/null
- name: Post Link
uses: thollander/actions-comment-pull-request@v2
if: github.event_name == 'pull_request'
with:
message: This pull request has been deployed to https://${{ steps.generate_domain_name.outputs.result }}
comment_tag: post_link_comment

0 comments on commit eaebcad

Please sign in to comment.