Skip to content

Commit cb2f9c2

Browse files
committed
Moved to using API via GH CLI for custom payload data delivery instead of relying on target workflow inputs
1 parent 991142b commit cb2f9c2

1 file changed

Lines changed: 43 additions & 21 deletions

File tree

.github/workflows/trigger-package-and-publish.yml

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
trigger:
1111
runs-on:
12-
group: 'Concordia-CKS'
12+
group: "FlexCloud-Rocky"
1313
env:
1414
target_owner: "${{ secrets.TARGET_OWNER }}"
1515
target_name: "${{ secrets.TARGET_NAME }}"
@@ -20,32 +20,54 @@ jobs:
2020
- name: Checkout Repository
2121
uses: actions/checkout@v6
2222

23-
- name: Platform Check
24-
run:
25-
cat /etc/os-release
23+
- name: Install DNF Config Manager
24+
run: |
25+
sudo dnf -y install 'dnf-command(config-manager)'
26+
27+
- name: Install GitHub CLI
28+
run: |
29+
sudo dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
30+
sudo dnf -y install gh
31+
32+
- name: Install gettext (for envsubvst)
33+
run: |
34+
sudo dnf -y install gettext
2635
27-
- name: Install GitHub CLI (Ubuntu)
36+
- name: Install YQ
2837
run: |
29-
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
30-
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
31-
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
32-
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
33-
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
34-
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
35-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
36-
&& sudo apt update \
37-
&& sudo apt install gh -y
38-
gh --version
38+
sudo curl -L -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
39+
sudo chmod a+x /usr/local/bin/yq
3940
4041
- name: Authenticate GitHub CLI Using Access Token
4142
run: |
4243
echo "${{ secrets.TARGET_REPOSITORY_ACCESS_TOKEN }}" | gh auth login --with-token
4344
gh auth status
4445
45-
- name: "Trigger Workflow in Target Repository"
46+
- name: Trigger Workflow in Target Repository (api)
4647
run: |
47-
gh workflow run \
48-
${{ env.target_workflow }} \
49-
--repo ${{ env.target_owner }}/${{ env.target_name }} \
50-
--ref 4.22 \
51-
;
48+
event_data=$(cat <<EOM | yq -o json -I 0 '.'
49+
event_type: "${{ env.event_type }}"
50+
client_payload:
51+
reference:
52+
name: "${{ github.ref_name }}"
53+
ref: "${{ github.ref }}"
54+
type: "${{ github.ref_type }}"
55+
sha: "${{ github.sha }}"
56+
repository:
57+
name: "${{ github.repository }}"
58+
url: "${{ github.repositoryUrl }}"
59+
run:
60+
id: "${{ github.run_id }}"
61+
iteration: "${{ github.run_number }}"
62+
workflow:
63+
name: "${{ github.workflow }}"
64+
ref: "${{ github.workflow_ref }}"
65+
sha: "${{ github.workflow_sha }}"
66+
EOM
67+
)
68+
echo "${event_data}" | \
69+
gh api --verbose \
70+
-X POST \
71+
--input - \
72+
/repos/${{ env.target_owner }}/${{ env.target_name }}/dispatches \
73+
;

0 commit comments

Comments
 (0)