Skip to content

Commit ec4e9c2

Browse files
committed
CI: add parent repository to repository dispatch if available
1 parent e526f74 commit ec4e9c2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/docker.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ jobs:
101101
dest-repo: ${{ fromJson(needs.build.outputs.dest-repo) }}
102102

103103
steps:
104+
- name: Gather environment variables (normal)
105+
if: github.event_name != 'repository_dispatch'
106+
run: |
107+
printf 'PAYLOAD_REPO_PARENT_NAME=%s\n' "${{ github.repository }}" >> $GITHUB_ENV
108+
printf 'PAYLOAD_REPO_PARENT_SHA=%s\n' "${{ github.sha }}" >> $GITHUB_ENV
109+
110+
- name: Gather environment variables (dispatch)
111+
if: github.event_name == 'repository_dispatch'
112+
run: |
113+
printf 'PAYLOAD_REPO_PARENT_NAME=%s\n' "${{ github.event.client_payload.parent_name }}" >> $GITHUB_ENV
114+
printf 'PAYLOAD_REPO_PARENT_SHA=%s\n' "${{ github.event.client_payload.parent_sha }}" >> $GITHUB_ENV
115+
104116
- name: Send Compile action
105117
run: |
106118
export DISPATCH_ACTION="$(printf 'run_build\n')"
@@ -113,7 +125,7 @@ jobs:
113125
repository: ${{ github.repository_owner }}/${{ matrix.dest-repo }}
114126
token: ${{ secrets.DISPATCH_TOKEN }}
115127
event-type: ${{ env.NEW_DISPATCH_ACTION }}
116-
client-payload: '{"ref": "${{ github.ref }}"}'
128+
client-payload: '{"ref": "${{ github.ref }}", "parent_name": "${{ env.PAYLOAD_REPO_PARENT_NAME }}", "parent_sha": "${{ env.PAYLOAD_REPO_PARENT_SHA }}"}'
117129

118130
- name: Repository Dispatch to specific ${{ matrix.dest-repo }}
119131
uses: peter-evans/repository-dispatch@v3
@@ -122,4 +134,4 @@ jobs:
122134
repository: ${{ matrix.dest-repo }}
123135
token: ${{ secrets.DISPATCH_TOKEN }}
124136
event-type: ${{ env.NEW_DISPATCH_ACTION }}
125-
client-payload: '{"ref": "${{ github.ref }}"}'
137+
client-payload: '{"ref": "${{ github.ref }}", "parent_name": "${{ env.PAYLOAD_REPO_PARENT_NAME }}", "parent_sha": "${{ env.PAYLOAD_REPO_PARENT_SHA }}"}'

0 commit comments

Comments
 (0)