Skip to content

Commit

Permalink
Merge pull request #368 from ntampakas/dev_autodeploy
Browse files Browse the repository at this point in the history
Support dev/stg auto deploy
  • Loading branch information
vplasencia authored Jan 30, 2024
2 parents ae30a07 + 92ff5b2 commit f5a20e2
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Deploy
on:
push:
branches: [main]
branches:
- main
- dev
workflow_dispatch:
inputs:
build:
Expand Down Expand Up @@ -36,13 +38,25 @@ jobs:
contents: read

steps:
- name: Check branch
- name: Manipulate Environment
id: manipulate
run: |
if [ "${{ env.DATA_ENV }}" = "prod" ]; then
if [ "$GITHUB_REF_NAME" != "main" ]; then
echo "Operation not permitted"
exit 1
fi
if [ "${{ github.event_name }}" = "push" ] && [ "$GITHUB_REF_NAME" = "main" ]; then
echo "env=prod" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "push" ] && [ "$GITHUB_REF_NAME" = "dev" ]; then
echo "env=stg" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "env=${{ env.DATA_ENV }}" >> $GITHUB_OUTPUT
else
echo "Operation not permitted"
exit 1
fi
- name: Check production branch
run: |
if [ "${{ steps.manipulate.outputs.env }}" = "prod" ] && [ "$GITHUB_REF_NAME" != "main" ]; then
echo "Operation not permitted"
exit 1
fi
- name: Checkout
Expand All @@ -59,8 +73,8 @@ jobs:

- name: Build and Push images to ECR
run: |
.github/scripts/build.sh ${{ env.DATA }} ${{ env.DATA_ENV }}
.github/scripts/build.sh ${{ env.DATA }} ${{ steps.manipulate.outputs.env }}
- name: Create Deployment
run: |
.github/scripts/deploy.sh ${{ env.DATA_ENV }}
.github/scripts/deploy.sh ${{ steps.manipulate.outputs.env }}

0 comments on commit f5a20e2

Please sign in to comment.