Skip to content

Commit

Permalink
Update deployment to trigger on dev push or hosted/ PR
Browse files Browse the repository at this point in the history
  • Loading branch information
sshrihar committed Sep 26, 2024
1 parent e46bd24 commit 1157754
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
35 changes: 1 addition & 34 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,10 @@ on:
default: "frontend-dev-ecs-cluster"

jobs:
check_files_changed:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
if: github.event_name != 'push'
permissions:
id-token: write
contents: write
outputs:
FILES_CHANGED: ${{ steps.changes.outputs.FILES_CHANGED }}
steps:
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"

- name: Checkout Code Repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Get list of changed files
id: changes
run: |
git fetch origin
BASE_BRANCH=${{ github.base_ref }}
echo "Base branch: $BASE_BRANCH"
# Compare the current branch (HEAD) with the base branch
changed_files=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
echo "FILES_CHANGED=$changed_files"
num_changed_files=$(echo "$changed_files" | wc -l)
echo "Number of Files changed=$num_changed_files"
echo "FILES_CHANGED=$num_changed_files" >> "$GITHUB_OUTPUT"
build_and_deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: [check_files_changed]
if: needs.check_files_changed.outputs.FILES_CHANGED != ''
if: github.event_name != 'push' || startsWith(github.head_ref, 'hosted/')
permissions:
id-token: write
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hosted-dev-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Hosted PR and Dev Deployment
on:
pull_request:
types: [opened, edited, reopened, synchronize]
types: [opened, reopened, synchronize]
push:
branches:
- dev
Expand Down

0 comments on commit 1157754

Please sign in to comment.