@@ -16,29 +16,22 @@ jobs:
16
16
ref : main
17
17
path : main_branch
18
18
fetch-depth : 1
19
- - name : Generate IaC from Main Branch
19
+ - name : Generate IAC for main branch
20
20
env :
21
21
APPCD_TOKEN : ${{ secrets.APPCD_TOKEN }}
22
22
APPCD_URL : ${{ secrets.APPCD_URL }}
23
- run : |
24
- mkdir -p artifact/main/ ./artifact/tmp
25
- docker run --rm \
26
- --workdir=/app/scan \
27
- -e APPCD_TOKEN=$APPCD_TOKEN \
28
- -e APPCD_URL=$APPCD_URL \
29
- -v ./main_branch:/app/scan \
30
- -v ./artifact/tmp:/tmp \
31
- -v ./artifact/main:/artifact/main \
32
- --entrypoint=appcd \
33
- ghcr.io/appcd-dev/appcd-dist/appcd-cli:v0.9.1 \
34
- generate --mode ci --lang Python --log 2 --output=/artifact/main/.appcd/charts --iac-type Helm
35
- cd artifact/main/.appcd/charts
36
- unzip scan.zip && rm scan.zip && ls -latr && pwd
37
- - name : Upload logs
38
- uses : actions/upload-artifact@v2
23
+ uses : appcd-dev/action@v0.0.1
24
+ with :
25
+ cloud : ' aws'
26
+ language : ' Python'
27
+ outputDir : ' ./artifact/main'
28
+ scanPath : ' ./main_branch'
29
+ targetCompute : ' k8s'
30
+ - name : Upload main artifacts
31
+ uses : actions/upload-artifact@v4
39
32
with :
40
- name : analyzer_logs_1
41
- path : artifact
33
+ name : main_branch_artifacts
34
+ path : artifact/main
42
35
- name : Checkout PR Branch
43
36
uses : actions/checkout@v4
44
37
with :
@@ -50,58 +43,36 @@ jobs:
50
43
run : echo "branch=$(basename ${{ github.head_ref}})" >> $GITHUB_OUTPUT
51
44
- name : echo branch name
52
45
run : echo ${{ steps.extract_branch.outputs.branch }}
53
- - name : Generate IaC from PR branch
46
+ - name : Generate IAC for PR branch
54
47
env :
55
48
APPCD_TOKEN : ${{ secrets.APPCD_TOKEN }}
56
49
APPCD_URL : ${{ secrets.APPCD_URL }}
57
- run : |
58
- mkdir -p artifact/${{ steps.extract_branch.outputs.branch }}/ ./artifact/tmp
59
- docker run --rm \
60
- --workdir=/app/scan \
61
- -v ./pr_branch/:/app/scan \
62
- -v ./artifact/${{ steps.extract_branch.outputs.branch }}:/artifact/${{ steps.extract_branch.outputs.branch }} \
63
- -v ./artifact/tmp:/tmp \
64
- -e APPCD_TOKEN=$APPCD_TOKEN \
65
- -e APPCD_URL=$APPCD_URL \
66
- --entrypoint=appcd \
67
- ghcr.io/appcd-dev/appcd-dist/appcd-cli:v0.9.1 \
68
- generate --mode ci --lang Python --log 2 --iac-type Helm --output=/artifact/${{ steps.extract_branch.outputs.branch }}/.appcd/charts
69
- cd artifact/${{ steps.extract_branch.outputs.branch }}/.appcd/charts
70
- unzip scan.zip && rm scan.zip && ls -latr
71
- - name : Upload logs
72
- uses : actions/upload-artifact@v2
50
+ uses : appcd-dev/action@v0.0.1
73
51
with :
74
- name : analyzer_logs_2
75
- path : artifact
76
- - name : Copy infrastructure files if empty
77
- run : |
78
- cd pr_branch
79
- mkdir -p infrastructure
80
- if [ -z "$(ls -A infrastructure/)" ]; then
81
- cp -r .appcd/infrastructure/app/rds/ infrastructure/
82
- git config --local user.email "action@github.com"
83
- git config --local user.name "GitHub Action"
84
- git add infrastructure/
85
- git commit -m "Adds IaC dependency files"
86
- git push
87
- fi
52
+ cloud : ' aws'
53
+ language : ' Python'
54
+ outputDir : ' ./artifact/pr_artifacts'
55
+ scanPath : ' ./pr_branch'
56
+ targetCompute : ' k8s'
57
+ - name : Upload PR artifacts
58
+ uses : actions/upload-artifact@v4
59
+ with :
60
+ name : pr_branch_artifacts
61
+ path : ./artifact/pr_artifacts
88
62
- name : Generate diff between Main and PR branch
89
63
run : |
90
64
mkdir -p pr_branch/deployment_files
91
- mv ./artifact/main/.appcd/charts/helm/scan_*/* pr_branch/deployment_files /
92
- cd pr_branch
93
- git config --local user.email "action@github .com"
94
- git config --local user.name "GitHub Action "
95
- git add deployment_files
65
+ cd ./artifact/main/
66
+ git init
67
+ git config --local user.email "bot@appcd .com"
68
+ git config --local user.name "AppCD Bot "
69
+ git add .
96
70
git commit -m "staging deployment files from main to compare them"
97
- rm -rf deploment_files
98
- cd ..
99
- mkdir -p pr_branch/deployment_files/
100
- cp -R artifact/${{ steps.extract_branch.outputs.branch }}/.appcd/charts/helm/scan_*/* pr_branch/deployment_files/
101
- cd pr_branch
71
+ rm -rf *
72
+ cp -R ../pr_artifacts/* .
102
73
git add .
103
- git diff --staged --output=../diff.txt deployment_files/ | cat
104
- cat ../diff.txt
74
+ git diff --staged --output=../../ diff.txt . | cat
75
+ cat ../../ diff.txt
105
76
- name : Comment PR with IaC Changes
106
77
uses : actions/github-script@v6
107
78
with :
0 commit comments