Continuous Delivery #188
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: Continuous Delivery | |
on: | |
schedule: | |
- cron: '0 3 * * 1,3,5' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_ENVIRONMENT_NAME: ${{ secrets.AWS_ENVIRONMENT_NAME }} | |
AWS_APPLICATION_NAME: ${{ secrets.AWS_APPLICATION_NAME }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install EB CLI using pip | |
run: | | |
python -m pip install --upgrade pip | |
pip install awsebcli | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install Dependencies | |
run: npm install | |
- name: Initialize EB Environment | |
run: (echo "1"; echo "n") | eb init -r ${{ env.AWS_DEFAULT_REGION }} ${{ env.AWS_APPLICATION_NAME }} | |
- name: Set EB Environment | |
run: eb use ${{ env.AWS_ENVIRONMENT_NAME }} -r ${{ env.AWS_DEFAULT_REGION }} | |
- name: Deploy to EB | |
run: | | |
if eb deploy; then | |
echo "Deployment succeeded✅" | |
else | |
echo "Deployment failed❌" | |
exit 1 | |
fi | |
- name: Purge Cloudflare Cache | |
run: | | |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/purge_cache" \ | |
-H "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data '{"purge_everything":true}' |