Add CI/CD #1
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: Push to ECR and deploy | |
on: | |
push: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build and push to ECR | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin 020353163849.dkr.ecr.eu-west-2.amazonaws.com | |
docker build -t diary . | |
docker tag diary:latest 020353163849.dkr.ecr.eu-west-2.amazonaws.com/diary:latest | |
docker push 020353163849.dkr.ecr.eu-west-2.amazonaws.com/diary:latest | |
- name: Deploy on Portainer | |
env: | |
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | |
run: | | |
curl -X POST -f \ | |
-H 'Content-Type: application/json' \ | |
--data '{"name": "diary", "DEPLOY_KEY": "${{ secrets.DEPLOY_KEY }}"}' \ | |
https://api.alexclifton.co.uk/deploy |