Skip to content

Commit

Permalink
Merge pull request #4 from Axcient/main
Browse files Browse the repository at this point in the history
Sending Dev to Staging
  • Loading branch information
Corey-Fogg authored Jun 3, 2024
2 parents 9757f50 + ab1b075 commit efcafa2
Show file tree
Hide file tree
Showing 2 changed files with 1,001 additions and 145 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy

on:
workflow_dispatch:
push:
branches:
- main
- staging
- production

defaults:
run:
shell: bash

permissions:
id-token: write
contents: read

jobs:
set-environment:
runs-on: ubuntu-latest
steps:
- name: Set environment based on ref
id: set_environment
run: |
echo "Starting environment setup..."
echo "Running on branch ${{ github.ref_name }}"
if [ "${{ github.ref_name }}" = "production" ]; then
echo "Setting environment to Production"
echo "env_name=Production" >> $GITHUB_OUTPUT
echo "using Production environment"
elif [ "${{ github.ref_name }}" = "staging" ]; then
echo "Setting environment to Staging"
echo "env_name=Staging" >> $GITHUB_OUTPUT
echo "using Staging environment"
else
echo "Setting environment to Development"
echo "env_name=Development" >> $GITHUB_OUTPUT
echo "using Development environment"
fi
echo "Environment setup complete."
outputs:
env_name: ${{steps.set_environment.outputs.env_name}}

deploy:
needs: set-environment
runs-on: ubuntu-latest
environment:
name: ${{ needs.set-environment.outputs.env_name }}
steps:
- name: Checking out files
uses: actions/checkout@v3
- name: Configuring AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.IAM_ROLE_GITHUB }}
role-session-name: GitHub-Action-Role
aws-region: ${{ vars.AWS_REGION }}
- name: Deploying files
env:
S3_BUCKET: ${{ vars.S3_BUCKET }}
run: |
echo "Starting S3 deployment..."
echo "Deploying files from ./dist/ to s3://$S3_BUCKET/"
aws s3 cp ./dist/ s3://$S3_BUCKET/dist/ --recursive --only-show-errors
echo "Deploying files from ./specs/ to s3://$S3_BUCKET/dist/"
aws s3 cp ./specs/ s3://$S3_BUCKET/specs/ --recursive --only-show-errors
echo "Deploying index.html to s3://$S3_BUCKET/specs/"
aws s3 cp ./index.html s3://$S3_BUCKET/ --only-show-errors
echo "S3 deployment complete."
- name: Invalidate CloudFront Cache
env:
AWS_REGION: ${{ vars.AWS_REGION }}
DISTRIBUTION_ID: ${{ vars.DISTRIBUTION_ID }}
run: |
echo "Invalidating CloudFront cache..."
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' --region $AWS_REGION
echo "CloudFront cache invalidation complete."
Loading

0 comments on commit efcafa2

Please sign in to comment.