Try again with the .env files :) #10
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: CMS CI/CD | |
on: | |
push: | |
paths: | |
- 'cms/**' | |
- '.github/workflows/cms*' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: Deploy CMS app | |
# if: (github.head_ref || github.ref_name) == 'main' || (github.head_ref || github.ref_name) == 'staging' | |
# if: (github.head_ref || github.ref_name) == 'staging' | |
if: (github.head_ref || github.ref_name) == 'infrastructure' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Extract branch name | |
shell: bash | |
run: | | |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
echo "##[set-output name=branch-upper;]$(echo ${GITHUB_REF#refs/heads/} | tr a-z A-Z )" | |
id: extract_branch | |
- name: Copy env variables to docker | |
run: | | |
echo "${{ secrets.CMS_STAGE_ENV_FILE }}" > cms/.env | |
- name: Configure AWS credentials | |
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: ap-northeast-2 | |
- 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: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: afoco-${{ steps.extract_branch.outputs.branch == 'main' && 'production' || 'staging' }} | |
IMAGE_TAG: cms-${{ github.sha }} | |
run: | | |
docker build -f Dockerfile.cms.prod -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |