@@ -21,254 +21,10 @@ docker run -d -p 8080:8080 devopsshield/devopsshield
2121![ image] ( https://github.com/devopsshield/devsecops-workshop/assets/112144174/46389907-1f3e-49b8-b6e5-0b81a9886001 )
22223 . Once logged in, click Setup Configuration
2323![ image] ( https://github.com/devopsshield/devsecops-workshop/assets/112144174/ec0a50d3-6773-4cd1-ad1f-8b0ef665083b )
24- 4 . Open a new issue or edit an exiting one to trigger the workflow. If the ` Issues ` tab is not visible, open your repository settings and enable it.
25- 5 . Go to ` Actions ` and see the details of your running workflow
26- 6 . After the workflow completes, a new label should be applied to your issue
27-
28- ## 5.2 Use a composite action
29-
30- 1 . Open the composite action file [ /.github/actions/hello-world-composite-action/action.yml] ( /.github/actions/hello-world-composite-action/action.yml )
31- 2 . Edit the file and copy the following YAML content at the end of the file:
32- ``` YAML
33- - name : Hello world
34- uses : actions/hello-world-javascript-action@main
35- with :
36- who-to-greet : " ${{ inputs.who-to-greet }}"
37- id : hello
38- - name : Echo the greeting's time
39- run : echo 'The time was ${{ steps.hello.outputs.time }}.'
40- shell : bash
41- ` ` `
42- 3. Commit the changes into a new ` feature/lab05` branch
43- 4. Open the workflow file [hello-world-composite.yml](/.github/workflows/hello-world-composite.yml)
44- 5. Edit the file and copy the following YAML content at the end of the file :
45- ` ` ` YAML
46- hello_world_job2:
47- runs-on: ubuntu-latest
48- name: A job2 to say hello
49- steps:
50- - uses: actions/checkout@v4
51- - id: hello-world
52- uses: ./.github/actions/hello-world-composite-action
53- with:
54- who-to-greet: 'Mona the Octocat from composite action'
55- - run: echo random-number from composite action ${{ steps.hello-world.outputs.random-number }}
56- shell: bash
57- ` ` `
58- 6. Update the workflow to run on pull_request events
59- ` ` ` YAML
60- on:
61- pull_request:
62- branches: [main]
63- workflow_dispatch:
64- ` ` `
65- 7. Commit the changes into the same `feature/lab05` branch
66- 8. Open a new pull request
67- 9. Go to `Actions` and see the details of your running workflow
68- 10. Complete the pull request and delete the source branch
69-
70- # # 5.3 Custom JS and Docker actions
71-
72- 1. Study the implementation of the custom action from the folder : [/.github/actions/](/.github/actions/)
73- 2. Open the workflow file [use-custom-actions.yml](/.github/workflows/use-custom-actions.yml)
74- 3. Edit the file and copy the following YAML content to update the issue title :
75- ` ` ` YAML
76- issue-title: "A joke for you from custom actions workflow"
77- ` ` `
78- 4. Commit the changes into the `main` branch
79- 5. Go to `Actions` and manually trigger the workflow by clicking on `Run Workflow` button
80- 6. See the details of your running workflow
81-
82- # # 5.4 (Optional) Create a JavaScript action
83- 1. Follow the guide to create a JavaScript action
84- - [Creating a JavaScript action](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action)
85- 2. Use your action in a workflow
86- ` ` ` YAML
87- - name: Hello world action step
88- id: hello
89- uses: <YOUR-USER-ACCOUNT>/hello-world-javascript-action@v1.1
90- with:
91- who-to-greet: 'Mona the Octocat'
92- ` ` `
93-
94- # # 5.5 Final
95- <details>
96- <summary>github-script.yml</summary>
97-
98- ` ` ` YAML
99- name: 05-1. GitHub Script - Thank you
100- on:
101- issues:
102- types: [opened, edited, reopened, labeled]
103-
104- # Limit the permissions of the GITHUB_TOKEN
105- permissions:
106- contents: read
107- issues: write
108-
109- jobs:
110- comment:
111- runs-on: ubuntu-latest
112- steps:
113- - uses: actions/github-script@v7
114- with:
115- github-token: ${{secrets.GITHUB_TOKEN}}
116- script: |
117- github.rest.issues.createComment({
118- issue_number: context.issue.number,
119- owner: context.repo.owner,
120- repo: context.repo.repo,
121- body: '👋 Thank you! We appreciate your contribution to this project.'
122- })
123- apply-label:
124- runs-on: ubuntu-latest
125- steps:
126- - uses: actions/github-script@v7
127- with:
128- script: |
129- github.rest.issues.addLabels({
130- issue_number: context.issue.number,
131- owner: context.repo.owner,
132- repo: context.repo.repo,
133- labels: ['Training']
134- })
135- ` ` `
136- </details>
137-
138- <details>
139- <summary>hello-world-composite-action/action.yml</summary>
140-
141- ` ` ` YAML
142- name: 'Hello World Composite Action'
143- description: 'Greet someone'
144- inputs:
145- who-to-greet: # id of input
146- description: 'Who to greet'
147- required: true
148- default: 'World'
149- outputs:
150- random-number:
151- description: "Random number"
152- value: ${{ steps.random-number-generator.outputs.random-id }}
153- runs:
154- using: "composite"
155- steps:
156- - run: echo Hello from composite action ${{ inputs.who-to-greet }}.
157- shell: bash
158- - id: random-number-generator
159- run: echo "random-id=$(echo $RANDOM)" >> $GITHUB_OUTPUT
160- shell: bash
161- - run: echo "${{ github.action_path }}" >> $GITHUB_PATH
162- shell: bash
163- - name: Hello world
164- uses: actions/hello-world-javascript-action@main
165- with:
166- who-to-greet: "${{ inputs.who-to-greet }}"
167- id: hello
168- - name: Echo the greeting's time
169- run: echo 'The time was ${{ steps.hello.outputs.time }}.'
170- shell: bash
171-
172- ` ` `
173- </details>
174-
175- <details>
176- <summary>hello-world-composite.yml</summary>
177-
178- ` ` ` YAML
179- name: 05-2. Hello World Composite
180-
181- on:
182- pull_request:
183- branches: [main]
184- workflow_dispatch:
185-
186- jobs:
187- hello_world_job1:
188- runs-on: ubuntu-latest
189- name: A job1 to say hello
190- steps:
191- - id: hello-world
192- uses: githubabcs/hello-world-composite-action@main
193- with:
194- who-to-greet: 'Hello from GH ABCs'
195- - run: echo random-number ${{ steps.hello-world.outputs.random-number }}
196- shell: bash
197- hello_world_job2:
198- runs-on: ubuntu-latest
199- name: A job2 to say hello
200- steps:
201- - uses: actions/checkout@v4
202- - id: hello-world
203- uses: ./.github/actions/hello-world-composite-action
204- with:
205- who-to-greet: 'Mona the Octocat from composite action'
206- - run: echo random-number from composite action ${{ steps.hello-world.outputs.random-number }}
207- shell: bash
208- ` ` `
209- </details>
210-
211- <details>
212- <summary>use-custom-actions.yml</summary>
213-
214- ` ` ` YAML
215- name: 05-3. Use Custom Actions (JS & Doker)
216-
217- on:
218- pull_request:
219- types: [labeled]
220- workflow_dispatch:
221-
222- # Limit the permissions of the GITHUB_TOKEN
223- permissions:
224- contents: read
225- issues: write
226-
227- jobs:
228-
229- js-custom-actions:
230- runs-on: ubuntu-latest
231- steps:
232- - uses: actions/checkout@v4
233-
234- - run: echo "🎉 Running the JS actions"
235-
236- - name: hello-action
237- uses: ./.github/actions/hello-world-js
238- if: ${{ success() }}
239-
240- - name: ha-ha
241- uses: ./.github/actions/joke-action
242- id: jokes
243-
244- - name: create-issue
245- uses: ./.github/actions/issue-maker-js
246- with:
247- repo-token: ${{secrets.GITHUB_TOKEN}}
248- joke: ${{steps.jokes.outputs.joke-output}}
249- issue-title: "A joke for you from custom actions workflow"
250-
251- docker-custom-actions:
252- runs-on: ubuntu-latest
253-
254- steps:
255- - uses: actions/checkout@v4
256-
257- - run: echo "🎉 Running the Docker actions"
258-
259- - name: hello-action
260- uses: ./.github/actions/hello-world-docker
261-
262- - name: meow
263- uses: ./.github/actions/cat-facts
264- id: cat
265-
266- - name: create-issue
267- uses: ./.github/actions/issue-maker-docker
268- with:
269- repoToken: ${{secrets.GITHUB_TOKEN}}
270- catFact: ${{steps.cat.outputs.fact}}
271- issueTitle: "A cat fact for you from ${{ github.repository_owner }}"
272-
273- ` ` `
274- </details>
24+ 4 . Now click on Quick Setup - Get Started
25+ ![ image] ( https://github.com/devopsshield/devsecops-workshop/assets/112144174/c39c4cb5-f86a-4f63-8dd0-9eed2a397818 )
26+ 5 . You can reuse the same GitHub PAT you used previously
27+ ![ image] ( https://github.com/devopsshield/devsecops-workshop/assets/112144174/5c092ae7-13eb-444d-b7a7-6f565847a43f )
28+ 6 . Now click on start setup now
29+ ![ image] ( https://github.com/devopsshield/devsecops-workshop/assets/112144174/3ea36eb2-95ca-4884-8700-723fe1c7f6c4 )
30+ 7 . Explore the results once the scan is done
0 commit comments