Skip to content

Commit

Permalink
Update ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien CAFFET committed Dec 8, 2024
1 parent 2ea5a7a commit 48187fe
Showing 1 changed file with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Wallet Frontend Deployment
name: Website Docs Deployment

on:
push:
branches:
- dev
- staging
- demo
- master

permissions:
Expand All @@ -17,9 +16,12 @@ jobs:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/master' && 'prod' || github.ref == 'refs/heads/staging' && 'staging' || github.ref == 'refs/heads/dev' && 'dev' }}
env:
PRODUCT: docs
APPLICATION: frontend
AWS_DEFAULT_REGION: eu-west-1
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
AWS_REGION: ${{ vars.AWS_REGION }}
PRODUCT: ${{ vars.PRODUCT }}
APPLICATION: ${{ vars.APPLICATION }}
ENVIRONMENT: ${{ vars.ENVIRONMENT }}
AWS_S3_BUCKET: ${{ vars.PRODUCT }}-${{ vars.APPLICATION }}-${{ vars.ENVIRONMENT }}-${{ vars.AWS_ACCOUNT_ID }}-${{ vars.AWS_REGION }}
BUILD_DIR: ./build
ALGOLIA_API_KEY: ${{ vars.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
Expand All @@ -32,27 +34,6 @@ jobs:
with:
node-version: '20'

- name: Set dev ENV
if: github.ref == 'refs/heads/dev'
run: |
echo "ENV=dev" >> $GITHUB_ENV
echo "AWS_ACCOUNT_ID=759055860286" >> $GITHUB_ENV
echo "AWS_S3_BUCKET=docs-frontend-dev-759055860286-eu-west-1" >> $GITHUB_ENV
- name: Set staging ENV
if: github.ref == 'refs/heads/staging'
run: |
echo "ENV=staging" >> $GITHUB_ENV
echo "AWS_ACCOUNT_ID=924226199168" >> $GITHUB_ENV
echo "AWS_S3_BUCKET=docs-frontend-staging-924226199168-eu-west-1" >> $GITHUB_ENV
- name: Set prod ENV
if: github.ref == 'refs/heads/master'
run: |
echo "ENV=prod" >> $GITHUB_ENV
echo "AWS_ACCOUNT_ID=255525589248" >> $GITHUB_ENV
echo "AWS_S3_BUCKET=docs-frontend-prod-255525589248-eu-west-1" >> $GITHUB_ENV
- name: Prepare .npmrc
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" >> .npmrc
Expand All @@ -67,8 +48,8 @@ jobs:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.PRODUCT }}-${{ env.APPLICATION }}-deployer-${{ env.AWS_DEFAULT_REGION }}-${{ env.ENV }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.PRODUCT }}-${{ env.APPLICATION }}-deployer-${{ env.AWS_REGION }}-${{ env.ENVIRONMENT }}
aws-region: ${{ env.AWS_REGION }}

- name: Deploy to S3
run: |
Expand All @@ -79,7 +60,7 @@ jobs:
cloudfrontdistids=$(aws cloudfront list-distributions | jq -r ".DistributionList.Items[].ARN")
for dist in $cloudfrontdistids; do
if [ $(aws cloudfront list-tags-for-resource --resource $dist --query "Tags.Items[?Key=='Application'].Value[]" --output text) == ${{ env.APPLICATION }} ] &&
[ $(aws cloudfront list-tags-for-resource --resource $dist --query "Tags.Items[?Key=='Environment'].Value[]" --output text) == ${{ env.ENV }} ]; then
[ $(aws cloudfront list-tags-for-resource --resource $dist --query "Tags.Items[?Key=='Environment'].Value[]" --output text) == ${{ env.ENVIRONMENT }} ]; then
CLOUDFRONT_DISTRIBUTION_IDS="$CLOUDFRONT_DISTRIBUTION_IDS ${dist##*/}"
fi
done
Expand Down

0 comments on commit 48187fe

Please sign in to comment.