Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit 118f94b

Browse files
committed
Merge branch 'develop'
2 parents 15a1cc2 + 5cc9ea7 commit 118f94b

31 files changed

+804
-869
lines changed

.github/cicd-sequence-diagram.mmd

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/cicd-sequence-diagram.svg

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: CI/CD
22

3-
# Trigger the workflow on push or pull request
43
on:
54
push:
65
branches:
@@ -10,40 +9,25 @@ on:
109
- alpha
1110
- '[0-9]+.x'
1211
- '[0-9]+.[0-9]+.x'
13-
pull_request:
1412

1513
jobs:
16-
build:
17-
name: Build
18-
if: "! (github.event_name == 'push' && github.ref == 'refs/heads/master')"
19-
runs-on: ubuntu-18.04
14+
appinspect-addon:
15+
name: AppInspect (Add-on)
16+
runs-on: ubuntu-20.04
17+
permissions:
18+
contents: read
2019
steps:
2120
- name: Checkout
22-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2322
- name: Build Add-on
2423
id: build-addon
2524
run: scripts/build.sh -a addon
26-
- name: Build App
27-
id: build-app
28-
run: scripts/build.sh -a app
29-
- uses: actions/upload-artifact@v1
30-
with:
31-
name: SplunkforPaloAltoNetworks-${{ github.run_id }}
32-
path: ${{ steps.build-app.outputs.path }}
33-
- uses: actions/upload-artifact@v1
25+
- name: Save Add-on Build Artifact
26+
uses: actions/upload-artifact@v1
27+
if: '! cancelled()'
3428
with:
3529
name: Splunk_TA_paloalto-${{ github.run_id }}
3630
path: ${{ steps.build-addon.outputs.path }}
37-
38-
appinspect-addon:
39-
name: AppInspect (Add-on)
40-
runs-on: ubuntu-18.04
41-
steps:
42-
- name: Checkout
43-
uses: actions/checkout@v2
44-
- name: Build Add-on
45-
id: build-addon
46-
run: scripts/build.sh -a addon
4731
- name: AppInspect
4832
run: scripts/appinspect.sh -a addon -r
4933
env:
@@ -58,13 +42,21 @@ jobs:
5842

5943
appinspect-app:
6044
name: AppInspect (App)
61-
runs-on: ubuntu-18.04
45+
runs-on: ubuntu-20.04
46+
permissions:
47+
contents: read
6248
steps:
6349
- name: Checkout
64-
uses: actions/checkout@v2
50+
uses: actions/checkout@v3
6551
- name: Build App
6652
id: build-app
6753
run: scripts/build.sh -a app
54+
- name: Save App Build Artifact
55+
uses: actions/upload-artifact@v1
56+
if: '! cancelled()'
57+
with:
58+
name: SplunkforPaloAltoNetworks-${{ github.run_id }}
59+
path: ${{ steps.build-app.outputs.path }}
6860
- name: AppInspect
6961
run: scripts/appinspect.sh -a app -r
7062
env:
@@ -79,22 +71,74 @@ jobs:
7971

8072
release:
8173
name: Release
82-
if: github.event_name == 'push' && github.ref != 'refs/heads/develop'
74+
if: github.ref != 'refs/heads/develop'
8375
needs: [appinspect-addon, appinspect-app]
84-
runs-on: ubuntu-18.04
76+
runs-on: ubuntu-20.04
77+
outputs:
78+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
79+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
80+
new_release_channel: ${{ steps.semantic.outputs.new_release_channel }}
8581
steps:
8682
- name: Checkout
87-
uses: actions/checkout@v2
83+
uses: actions/checkout@v3
8884
- name: Create release and publish
89-
id: release
90-
uses: cycjimmy/semantic-release-action@v2
85+
id: semantic
86+
uses: cycjimmy/semantic-release-action@v3
9187
with:
9288
semantic_version: 17.1.1
9389
extra_plugins: |
9490
conventional-changelog-conventionalcommits@^4.4.0
95-
@semantic-release/git@^9.0.0
9691
@semantic-release/exec@^5.0.0
9792
env:
9893
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9994
SPLUNK_USER: ${{ secrets.SPLUNK_USER }}
10095
SPLUNK_PASS: ${{ secrets.SPLUNK_PASS }}
96+
97+
docker-build:
98+
name: Docker Build
99+
needs: [release]
100+
# When to run, per https://github.com/actions/runner/issues/491#issuecomment-850884422
101+
if: always() && (needs.release.result == 'success' || needs.release.result == 'skipped')
102+
runs-on: ubuntu-20.04
103+
env:
104+
REGISTRY: ghcr.io
105+
IMAGE_NAME: ${{ github.repository_owner }}/splunk-demo
106+
steps:
107+
- name: Checkout
108+
uses: actions/checkout@v3
109+
110+
- name: Determine docker tags and labels
111+
id: meta
112+
uses: docker/metadata-action@v3
113+
with:
114+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
115+
tags: |
116+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
117+
type=ref,event=branch
118+
119+
- name: Set the version in app.conf
120+
if: needs.release.result == 'success' && needs.release.outputs.new_release_published == 'true'
121+
run: scripts/set-version.sh ${{ needs.release.outputs.new_release_version }} ${{ needs.release.outputs.new_release_channel }}
122+
123+
- name: Create docker version tag
124+
id: versiontag
125+
if: needs.release.result == 'success' && needs.release.outputs.new_release_published == 'true'
126+
run: echo "::set-output name=versiontag::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.new_release_version }}"
127+
128+
- name: Login to Container registry
129+
uses: docker/login-action@v1
130+
with:
131+
registry: ${{ env.REGISTRY }}
132+
username: ${{ github.actor }}
133+
password: ${{ secrets.GITHUB_TOKEN }}
134+
135+
- name: Build and push Docker image
136+
uses: docker/build-push-action@v2
137+
with:
138+
context: .
139+
file: demo/Dockerfile
140+
push: true
141+
tags: |
142+
${{ steps.meta.outputs.tags }}
143+
${{ steps.versiontag.outputs.versiontag }}
144+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/pr-appinspect.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: PR App Inspect
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
appinspect-addon:
10+
name: AppInspect (Add-on)
11+
runs-on: ubuntu-18.04
12+
# Remove write permissions
13+
permissions:
14+
contents: read
15+
steps:
16+
# Checkout unsafe code
17+
- name: Checkout PR
18+
uses: actions/checkout@v3
19+
with:
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
path: pr
22+
persist-credentials: false
23+
# Checkout safe code
24+
- name: Checkout build scripts
25+
uses: actions/checkout@v3
26+
with:
27+
path: tools
28+
# Replace build script in unsafe code with scripts from safe code
29+
- name: Setup build scripts
30+
run: |
31+
rm -rf pr/scripts
32+
mv tools/scripts pr
33+
- name: Build Add-on
34+
id: build-addon
35+
working-directory: pr
36+
run: scripts/build.sh -a addon
37+
- name: Save Add-on Build Artifact
38+
uses: actions/upload-artifact@v1
39+
if: '! cancelled()'
40+
with:
41+
name: Splunk_TA_paloalto-${{ github.run_id }}
42+
path: pr/${{ steps.build-addon.outputs.path }}
43+
- name: AppInspect
44+
working-directory: pr
45+
run: scripts/appinspect.sh -a addon -r
46+
env:
47+
SPLUNK_USER: ${{ secrets.SPLUNK_USER }}
48+
SPLUNK_PASS: ${{ secrets.SPLUNK_PASS }}
49+
- name: Save report
50+
uses: actions/upload-artifact@v1
51+
if: '! cancelled()'
52+
with:
53+
name: Report-Splunk_TA_paloalto-${{ github.run_id }}.html
54+
path: pr/_build/Splunk_TA_paloalto-${{ github.run_id }}.html
55+
56+
appinspect-app:
57+
name: AppInspect (App)
58+
runs-on: ubuntu-18.04
59+
permissions:
60+
contents: read
61+
steps:
62+
- name: Checkout PR
63+
uses: actions/checkout@v3
64+
with:
65+
ref: ${{ github.event.pull_request.head.sha }}
66+
path: pr
67+
persist-credentials: false
68+
- name: Checkout build scripts
69+
uses: actions/checkout@v3
70+
with:
71+
path: tools
72+
- name: Setup build scripts
73+
run: |
74+
rm -rf pr/scripts
75+
mv tools/scripts pr
76+
- name: Build App
77+
id: build-app
78+
working-directory: pr
79+
run: scripts/build.sh -a app
80+
- name: Save App Build Artifact
81+
uses: actions/upload-artifact@v1
82+
if: '! cancelled()'
83+
with:
84+
name: SplunkforPaloAltoNetworks-${{ github.run_id }}
85+
path: pr/${{ steps.build-app.outputs.path }}
86+
- name: AppInspect
87+
working-directory: pr
88+
run: scripts/appinspect.sh -a app -r
89+
env:
90+
SPLUNK_USER: ${{ secrets.SPLUNK_USER }}
91+
SPLUNK_PASS: ${{ secrets.SPLUNK_PASS }}
92+
- name: Save report
93+
uses: actions/upload-artifact@v1
94+
if: '! cancelled()'
95+
with:
96+
name: Report-SplunkforPaloAltoNetworks-${{ github.run_id }}.html
97+
path: pr/_build/SplunkforPaloAltoNetworks-${{ github.run_id }}.html

CONTRIBUTING.md

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- [Bug fixes and features](#bug-fixes-and-features)
88
- [Test changes in your branch](#test-changes-in-your-branch)
99
- [Publish a new release (for maintainers)](#publish-a-new-release-for-maintainers)
10-
- [CI/CD Sequence diagram](#cicd-sequence-diagram)
10+
- [CI/CD Release Process](#cicd-release-process)
1111

1212
## How to contribute
1313

@@ -96,10 +96,9 @@ directories and reloads them in Splunk when a change is detected.
9696

9797
## Publish a new release (for maintainers)
9898

99-
Requires node and semantic-release npm package
100-
10199
```
102100
# Test the release process on develop
101+
# (this requires node and semantic-release npm package)
103102
semantic-release --dry-run --no-ci --branches=develop
104103
105104
# Verify in the output that the next version is set correctly
@@ -113,24 +112,63 @@ git push origin master
113112
# At this point, GitHub Actions is testing the release
114113
# then building it for publication
115114
116-
# There is a manual step here. You'll have to get the build
117-
# from the GitHub Actions artifacts and publish it on SplunkBase
118-
# manually. We can automate this when the SplunkBase API is more mature.
119-
120115
# Now, sync your local with the remote to pull the new
121-
# commits made by the release bot.
122-
git fetch --all --tags
123-
git pull origin master
116+
# tags created in the release process
117+
git fetch --tags
124118
git checkout develop
125-
git merge master
126-
git push origin develop
127119
128120
# Now you're ready to branch again and work on the next feature.
129121
```
130122

131-
## CI/CD Sequence diagram
132-
133-
![Sequence diagram](./.github/cicd-sequence-diagram.svg)
134-
135-
- [Diagram source](./.github/cicd-sequence-diagram.mmd)
136-
- [CI/CD Workflow yaml](./.github/workflows/ci.yml)
123+
## CI/CD Release Process
124+
125+
```mermaid
126+
sequenceDiagram
127+
%% This is a mermaid file
128+
%% See https://mermaid-js.github.io
129+
130+
participant G as GitHub
131+
participant A as GH Actions
132+
participant I as Splunk AppInspect
133+
participant S as SplunkBase
134+
participant C as GH Container Registry
135+
participant K as GCP GKE
136+
137+
G-)+A: Push Triggers GitHub Action
138+
139+
%% AppInspect
140+
rect rgb(153,255,170,.2)
141+
note left of I: AppInspect
142+
A->>+I: Trigger AppInspect of App and Add-on
143+
I-->>-A: AppInspect completed
144+
A->>+I: Request HTML report
145+
I-->>-A: Return HTML report
146+
end
147+
148+
%% Release
149+
rect rgb(217,179,255,.2)
150+
note left of S: Release
151+
A->>A: Determines new version
152+
A->>G: Create GH Release w/ release note
153+
A->>A: Build App & Add-on w/ incremented version
154+
A->>S: Publish release
155+
A->>S: Verify publish
156+
end
157+
158+
%% Docker build
159+
rect rgb(128,170,255,.2)
160+
note left of C: Docker build
161+
A->>A: Build docker image
162+
A->>-C: Publish docker image
163+
end
164+
165+
%% Demo server
166+
rect rgb(255,221,153,.2)
167+
note right of C: Demo server
168+
loop weekly
169+
K->>+K: Cloud Scheduler triggers Cloud Function
170+
K->>C: Pull latest docker demo
171+
K->>-K: Restart Demo
172+
end
173+
end
174+
```

0 commit comments

Comments
 (0)