Skip to content

Commit 4536141

Browse files
authored
Dispatch example (#12)
1 parent 2e59fae commit 4536141

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

.github/workflows/dispatch-example.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: GitHub action dispath
33
on:
44
workflow_dispatch:
55
inputs:
6-
source-regurl-tag:
6+
source_regurl_tag:
77
required: true
88
default: ""
99
description: "Container image registry URL with tag. e.g., gcr.io/project-id-372417/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2"
10-
target-regurl:
10+
target_regurl:
1111
required: true
1212
default: ""
1313
description: "Container image registry URL WITHOUT tag e.g., gcr.io/project-id-372417/target-image"
@@ -17,17 +17,23 @@ jobs:
1717
name: Copy container image
1818
runs-on: ubuntu-latest
1919
env:
20-
SOURCE_IMAGE_WITH_TAG: ${{ github.env.inputs.source-regurl-tag }}
21-
TARGET_IMAGE_URL: ${{ github.env.inputs.target-regurl }}
20+
IMAGE_TAG: ''
21+
PROD_IMAGE: ''
2222
steps:
23+
- name: print
24+
run: |
25+
echo ${{ inputs.source_regurl_tag }}
26+
echo ${{ inputs.target-tag }}
2327
- name: Get image tag
2428
run: |
25-
echo IMAGE_TAG=$(echo ${{ env.SOURCE_IMAGE_WITH_TAG }} | cut -d":" -f2) >> $GITHUB_ENV
29+
echo IMAGE_TAG=$(echo ${{ inputs.source_regurl_tag }} | cut -d":" -f2) >> $GITHUB_ENV
30+
echo "PROD_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV
2631
2732
- name: Summary
2833
run: |
29-
echo "SOURCE_IMAGE_WITH_TAG=${{ env.SOURCE_IMAGE_WITH_TAG }}" >> $GITHUB_STEP_SUMMARY
30-
echo "PROD_IMAGE=${{ env.TARGET_IMAGE_URL }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY
34+
echo "source_regurl_tag: ${{ inputs.source_regurl_tag }}" >> $GITHUB_STEP_SUMMARY
35+
echo "target_regurl: ${{ inputs.target_regurl }}" >> $GITHUB_STEP_SUMMARY
36+
echo "PROD_IMAGE: ${{ env.PROD_IMAGE }}" >> $GITHUB_STEP_SUMMARY
3137
3238
- uses: hmarr/debug-action@v2
3339
if: always()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ref": "develop",
33
"inputs": {
4-
"source-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
5-
"target-url": "gcr.io/project-id/target-image"
4+
"source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
5+
"target_regurl": "gcr.io/project-id/target-image"
66
}
77
}

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ Provides GitHub Workflow and Action samples.
7171
cp .github/workflows/dispatch-request-exmple.json request-body.json
7272
cat request-body.json
7373

74+
TOKEN="example-github_pat_XXXXX"
75+
7476
curl -d @request-body.json \
7577
-H "Accept: application/vnd.github+json" \
7678
-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+
-H "Authorization: Bearer $TOKEN" \
80+
https://api.github.com/repos/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches
7981
```
8082

8183
develop branch:
@@ -86,8 +88,8 @@ develop branch:
8688
{
8789
"ref": "develop",
8890
"inputs": {
89-
"test-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
90-
"prod-url": "gcr.io/project-id/target-image"
91+
"source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
92+
"target_regurl": "gcr.io/project-id/target-image"
9193
}
9294
}
9395
```
@@ -96,10 +98,10 @@ master branch:
9698

9799
```json
98100
{
99-
"ref": "develop",
101+
"ref": "master",
100102
"inputs": {
101-
"test-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
102-
"prod-url": "gcr.io/project-id/target-image"
103+
"source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2",
104+
"target_regurl": "gcr.io/project-id/target-image"
103105
}
104106
}
105107
```

0 commit comments

Comments
 (0)