File tree Expand file tree Collapse file tree 4 files changed +86
-0
lines changed
Expand file tree Collapse file tree 4 files changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ name : GitHub action dispath
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ source-regurl-tag :
7+ required : true
8+ default : " "
9+ description : " Container image registry URL with tag. e.g., gcr.io/project-id-372417/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2"
10+ target-regurl :
11+ required : true
12+ default : " "
13+ description : " Container image registry URL WITHOUT tag e.g., gcr.io/project-id-372417/target-image"
14+
15+ env :
16+ SOURCE_IMAGE_WITH_TAG : ${{ github.env.inputs.source-regurl-tag }}
17+ TARGET_IMAGE_URL : ${{ github.env.inputs.target-regurl }}
18+
19+ jobs :
20+ copy_container_image :
21+ name : Copy container image
22+ runs-on : ubuntu-latest
23+ steps :
24+ - name : Get image tag
25+ run : |
26+ echo IMAGE_TAG=$(echo ${{ env.SOURCE_IMAGE_WITH_TAG }} | cut -d":" -f2) >> $GITHUB_ENV
27+
28+ - name : Summary
29+ run : |
30+ echo "SOURCE_IMAGE_WITH_TAG=${{ env.SOURCE_IMAGE_WITH_TAG }}" >> $GITHUB_STEP_SUMMARY
31+ echo "PROD_IMAGE=${{ env.TARGET_IMAGE_URL }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY
32+
33+ - uses : hmarr/debug-action@v2
34+ if : always()
Original file line number Diff line number Diff line change 1+ {
2+ "ref" : " develop" ,
3+ "inputs" : {
4+ "source-url-tag" : " gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" ,
5+ "target-url" : " gcr.io/project-id/target-image"
6+ }
7+ }
Original file line number Diff line number Diff line change 2525# # google-github-actions/auth@v1
2626gha-creds- * .json
2727
28+ # Dispatch Examples
29+ request- * .json
30+
2831# Byte-compiled / optimized / DLL files
2932__pycache__ /
3033* .py [cod ]
Original file line number Diff line number Diff line change @@ -65,10 +65,52 @@ Provides GitHub Workflow and Action samples.
6565| [ google-github-actions/auth@v1] ( https://github.com/google-github-actions/auth ) | GitHub Action authenticates to Google Cloud |
6666| [ EnricoMi/publish-unit-test-result-action/composite@v2] ( https://github.com/EnricoMi/publish-unit-test-result-action ) | Publish Test Results |
6767
68+ ## Dispatch
69+
70+ ``` bash
71+ cp .github/workflows/dispatch-request-exmple.json request-body.json
72+ cat request-body.json
73+
74+ curl -d @request-body.json \
75+ -H " Accept: application/vnd.github+json" \
76+ -H " X-GitHub-Api-Version: 2022-11-28" \
77+ -H " Authorization: Bearer <your-token>" \
78+ https://github.com/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches
79+ ```
80+
81+ develop branch:
82+
83+ [ .github/workflows/dispatch-request-exmple.json] ( .github/workflows/dispatch-request-exmple.json )
84+
85+ ``` json
86+ {
87+ "ref" : " develop" ,
88+ "inputs" : {
89+ "test-url-tag" : " gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" ,
90+ "prod-url" : " gcr.io/project-id/target-image"
91+ }
92+ }
93+ ```
94+
95+ master branch:
96+
97+ ``` json
98+ {
99+ "ref" : " develop" ,
100+ "inputs" : {
101+ "test-url-tag" : " gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" ,
102+ "prod-url" : " gcr.io/project-id/target-image"
103+ }
104+ }
105+ ```
106+
107+
68108## Reference
69109
70110- [ GitHub Actions /Using workflows / Cache dependencies / Caching dependencies to speed up workflows] ( https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches )
71111
72112- https://github.com/actions/cache
73113
74114- https://github.com/actions/cache/blob/main/examples.md#java---gradle
115+
116+ - https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
You can’t perform that action at this time.
0 commit comments