Skip to content

Commit 0080078

Browse files
authored
[CI] Move to appcd-dev action (#46)
* trigger pipeline * build * image * See if action does work * update for PR branch * diff * Debug * unwanted change * docker build * remove tree * better diff * fix build
1 parent 0c7944b commit 0080078

File tree

3 files changed

+59
-73
lines changed

3 files changed

+59
-73
lines changed

.github/workflows/appcd-iac-pr-diff.yml

+33-62
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,22 @@ jobs:
1616
ref: main
1717
path: main_branch
1818
fetch-depth: 1
19-
- name: Generate IaC from Main Branch
19+
- name: Generate IAC for main branch
2020
env:
2121
APPCD_TOKEN: ${{ secrets.APPCD_TOKEN }}
2222
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
3932
with:
40-
name: analyzer_logs_1
41-
path: artifact
33+
name: main_branch_artifacts
34+
path: artifact/main
4235
- name: Checkout PR Branch
4336
uses: actions/checkout@v4
4437
with:
@@ -50,58 +43,36 @@ jobs:
5043
run: echo "branch=$(basename ${{ github.head_ref}})" >> $GITHUB_OUTPUT
5144
- name: echo branch name
5245
run: echo ${{ steps.extract_branch.outputs.branch }}
53-
- name: Generate IaC from PR branch
46+
- name: Generate IAC for PR branch
5447
env:
5548
APPCD_TOKEN: ${{ secrets.APPCD_TOKEN }}
5649
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
7351
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
8862
- name: Generate diff between Main and PR branch
8963
run: |
9064
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 .
9670
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/* .
10273
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
10576
- name: Comment PR with IaC Changes
10677
uses: actions/github-script@v6
10778
with:

.github/workflows/build.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,21 @@ jobs:
1111
timeout-minutes: 10
1212
steps:
1313
- uses: actions/checkout@v1
14+
with:
15+
fetch-depth: 1
1416
- name: pull latest
1517
run: make pull
1618
- name: Build image
1719
run: make build
18-
#- name: Test code format -- pre-commit
19-
# run: make lint
20+
- name: Generate IAC for main branch
21+
env:
22+
APPCD_TOKEN: ${{ secrets.APPCD_TOKEN }}
23+
APPCD_URL: ${{ secrets.APPCD_URL }}
24+
uses: appcd-dev/action@v0.0.1
25+
with:
26+
cloud: 'aws'
27+
language: 'Python'
28+
outputDir: './.appcd/charts'
29+
scanPath: '.'
30+
targetCompute: 'k8s'
31+

.github/workflows/docker-publish.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,20 @@ jobs:
9292
- name: Create required directories
9393
run: mkdir -p .appcd/charts && chmod 777 .appcd -R
9494

95-
- name: run appCD
96-
run: |
97-
docker run --rm \
98-
--workdir=/code \
99-
-v $PWD:/code ghcr.io/appcd-dev/appcd-dist/appcd-cli:v0.9.0 \
100-
generate --mode ci --lang Python --iac-type Helm --output=/code/.appcd/charts
101-
cd .appcd/charts && ls
102-
unzip DogeAPI.zip && rm DogeAPI.zip
103-
95+
- name: Generate IAC for main branch
96+
env:
97+
APPCD_TOKEN: ${{ secrets.APPCD_TOKEN }}
98+
APPCD_URL: ${{ secrets.APPCD_URL }}
99+
uses: appcd-dev/action@v0.0.1
100+
with:
101+
cloud: 'aws'
102+
language: 'Python'
103+
outputDir: './.appcd/charts'
104+
scanPath: './main_branch'
105+
targetCompute: 'k8s'
104106
- name: Inflate helm chart in gitops/
105107
run: |
108+
tree
106109
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
107110
helm template demo-chart ./.appcd/charts/dogeapi -f ./.appcd/overrides/dogeapi/values.yaml --set image.tag=${{ steps.version.outputs.image_tag }} > ./gitops/prod/dogeapi.yaml
108111
else

0 commit comments

Comments
 (0)