Deploy-Prod #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy-Prod | |
on: | |
workflow_dispatch: | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
- name: Start containers | |
run: docker-compose -f "docker-compose.yml" up -d | |
working-directory: src | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2.2' | |
bundler-cache: true | |
working-directory: src | |
- run: bundle exec rails db:create | |
working-directory: src | |
- run: bundle exec rails db:migrate | |
working-directory: src | |
- run: bundle exec bundle exec rake | |
working-directory: src | |
deploy: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.19.0' | |
- name: Install AWS CLI | |
run: | | |
sudo apt-get install -y python3-pip | |
pip3 install awscliv2 | |
- name: Configure AWS Credentials | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Install CDK | |
run: npm install -g aws-cdk@latest | |
- name: Install CDK Dependencies | |
run: npm install | |
working-directory: ./deployment | |
- name: Copy secrets file | |
run: cp secrets.yml.example secrets.yml | |
working-directory: ./src/config | |
- name: CDK Deploy | |
run: cdk deploy SchengTrackProd --require-approval never | |
working-directory: ./deployment | |
cacheInvalidate: | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install AWS CLI | |
run: | | |
sudo apt-get install -y python3-pip | |
pip3 install awscliv2 | |
- name: Configure AWS Credentials | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Perform CloudFront Invalidation | |
id: cloudfront_invalidation | |
run: | | |
invalidation_id=$(aws cloudfront create-invalidation --distribution-id E1KF4KLAR0V084 --paths '/*' --query Invalidation.Id --output text) | |
echo "invalidationId=${invalidation_id}" >> $GITHUB_OUTPUT | |
- name: Wait for CloudFront Invalidation | |
run: aws cloudfront wait invalidation-completed --distribution-id E1KF4KLAR0V084 --id "${{ steps.cloudfront_invalidation.outputs.invalidationId }}" | |
- name: Recache main urls | |
run: ./recache.sh urls-prod.txt | |
working-directory: ./deployment/scripts | |