Promote chatops to staging #97
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: CI Copied Files Check | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
changed_files: | |
runs-on: ubuntu-latest | |
name: Test changed-files | |
outputs: | |
staging_result: ${{ steps.staging-check.outputs.result }} | |
prod_result: ${{ steps.prod-check.outputs.result }} | |
any_changed: ${{ steps.changed-files.outputs.any_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files in specific repo folders | |
id: changed-files | |
uses: tj-actions/changed-files@v45 | |
with: | |
files_yaml: | | |
staging: | |
- charts/staging/** | |
prod: | |
- charts/prod/** | |
- name: Run step if any file(s) in staging env change | |
id: staging-check | |
if: steps.changed-files.outputs.staging_any_changed == 'true' | |
env: | |
STAGING_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.staging_all_changed_files }} | |
run: | | |
echo "One or more files in the staging folder has changed." | |
echo "Files that have changed: $STAGING_ALL_CHANGED_FILES" | |
echo "result=true" >> "$GITHUB_OUTPUT" | |
for file in ${{ steps.changed-files.outputs.staging_all_changed_files }}; do | |
res=$( ${{ github.workspace }}/.github/workflows/pr_check_copies.sh "$file" "staging" "dev" ) | |
echo $res | |
if [ "$res" -eq 1 ]; then | |
echo "result=false" >> "$GITHUB_OUTPUT" | |
break; | |
fi | |
done | |
- name: Run step if any file(s) in prod env change | |
id: prod-check | |
if: steps.changed-files.outputs.prod_any_changed == 'true' | |
env: | |
PROD_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.prod_all_changed_files }} | |
run: | | |
echo "One or more files in the prod folder has changed." | |
echo "Files that have changed: $PROD_ALL_CHANGED_FILES" | |
echo "result=true" >> "$GITHUB_OUTPUT" | |
for file in ${{ steps.changed-files.outputs.prod_all_changed_files }}; do | |
res=$( ${{ github.workspace }}/.github/workflows/pr_check_copies.sh "$file" "prod" "staging" ) | |
echo $res | |
if [ "$res" -eq 1 ]; then | |
echo "result=false" >> "$GITHUB_OUTPUT" | |
break; | |
fi | |
done | |
comment_pr: | |
needs: changed_files | |
if: ${{ contains(needs.changed_files.outputs.any_changed, 'true') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: comment_staging_pr | |
uses: actions/github-script@v7 | |
if: contains(needs.changed_files.outputs.staging_result, 'true') | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '👋 All changes for Staging are an exact match to Dev' | |
}) | |
- name: comment_prod_pr | |
uses: actions/github-script@v7 | |
if: contains(needs.changed_files.outputs.prod_result, 'true') | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '👋 All changes for Prod are an exact match to Staging' | |
}) | |