forked from stfc/cloud-deployed-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (94 loc) · 3.48 KB
/
pr_copied_files.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: CI Copied Files Check
on:
push:
branches:
- check_pr_copies
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
with:
ref: check_pr_copies
- 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/**
# clusters/staging/**
# clusters/prod/**
# secrets/staging/**
# secrets/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=$( sudo ./scripts/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=$( sudo ./scripts/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'
})