Merge pull request #5 from KogoCampus/KG-349 #27
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 to ECR | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
AWS_REGION: us-west-2 | |
ECR_REPOSITORY: course-scraper-job | |
ECR_REGISTRY: 992382730467.dkr.ecr.us-west-2.amazonaws.com | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install SOPS | |
run: | | |
SOPS_VERSION=3.9.1 | |
curl -LO "https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.amd64" | |
sudo mv sops-v${SOPS_VERSION}.linux.amd64 /usr/local/bin/sops | |
sudo chmod +x /usr/local/bin/sops | |
- name: Setup AWS CLI | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Decrypt production environment file | |
run: | | |
sops --config .sops/sops.yaml -d .sops/prod.env > .env | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
- name: Make deploy script executable | |
run: chmod +x .github/deploy-apprunner.sh | |
- name: Deploy to App Runner | |
run: .github/deploy-apprunner.sh |