Skip to content

Commit 377de27

Browse files
author
Michael Henderson
committed
fix branch detection
On kfutil, the repo name (KFUTIL_ARG) becomes the branch, not the repo/ref (TARGET_REPO_BRANCH).
1 parent 120aa03 commit 377de27

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

.github/workflows/update-stores.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
if: github.event_name == 'repository_dispatch'
2727
id: set-env-vars-from-payload
2828
run: |
29-
echo "TARGET_REPO_BRANCH=${{ github.event.client_payload.targetRepo }}" | tee -a $GITHUB_ENV
29+
echo "TARGET_REPO_BRANCH=${{ github.event.client_payload.targetRef }}" | tee -a $GITHUB_ENV
3030
echo "KFUTIL_ARG=${{ github.event.client_payload.targetRepo }}" | tee -a $GITHUB_ENV
3131
- name: Check Open PRs for Existing Branch
3232
id: check-branch
@@ -41,8 +41,8 @@ jobs:
4141
repo,
4242
state: "open"
4343
});
44-
// Filter out ones matching the TARGET_REPO_BRANCH from payload (repository_dispatch) or input (workflow_dispatch)
45-
const filteredData = pulls.data.filter(item => item.head.ref === '${{ env.TARGET_REPO_BRANCH }}');
44+
// Filter out ones matching the KFUTIL_ARG from payload (repository_dispatch) or input (workflow_dispatch)
45+
const filteredData = pulls.data.filter(item => item.head.ref === '${{ env.KFUTIL_ARG }}'); // Look for an existing branch with the orchestrator repo name
4646
const isBranch = (filteredData.length > 0)
4747
if (isBranch) {
4848
const {
@@ -56,7 +56,7 @@ jobs:
5656
}
5757
console.log(`Branch exists?`)
5858
console.log(filteredData.length > 0)
59-
console.log(`targetRepo: ${{env.TARGET_REPO_BRANCH}}`)
59+
console.log(`targetRepo: ${{env.KFUTIL_ARG}}`)
6060
- name: set env.PR_BRANCH value for jobs
6161
run: |
6262
echo "PR_BRANCH=${{steps.check-branch.outputs.PR_BRANCH}}" | tee -a $GITHUB_ENV
@@ -71,7 +71,7 @@ jobs:
7171
.github
7272
path: './merge-folder/'
7373
token: ${{ secrets.SDK_SYNC_PAT }}
74-
ref: '${{env.TARGET_REPO_BRANCH}}'
74+
ref: '${{env.KFUTIL_ARG}}'
7575

7676
# If the branch does not exist, first check out the main branch from kfutil.
7777
- name: Check out main
@@ -155,11 +155,11 @@ jobs:
155155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156156
with:
157157
add: store_types.json --force
158-
message: Update store_types.json for ${{env.TARGET_REPO_BRANCH}}
158+
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}
159159
author_name: Keyfactor
160160
author_email: keyfactor@keyfactor.github.io
161161
cwd: './merge-folder/'
162-
new_branch: ${{env.TARGET_REPO_BRANCH}}
162+
new_branch: ${{env.KFUTIL_ARG}}
163163

164164
- name: Add and Commit to existing branch
165165
if: ${{ env.UPDATE_FILE == 'T' && env.PR_BRANCH == 'commit' }}
@@ -168,7 +168,7 @@ jobs:
168168
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169169
with:
170170
add: store_types.json --force
171-
message: Update store_types.json for ${{env.TARGET_REPO_BRANCH}}
171+
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}
172172
author_name: Keyfactor
173173
author_email: keyfactor@keyfactor.github.io
174174
cwd: './merge-folder/'
@@ -178,20 +178,20 @@ jobs:
178178
uses: actions/github-script@v6
179179
with:
180180
script: |
181-
console.log(`Created ${{env.TARGET_REPO_BRANCH}} `)
182-
console.log("Commit to ${{env.TARGET_REPO_BRANCH}} for PR")
181+
console.log(`Created ${{env.KFUTIL_ARG}} `)
182+
console.log("Commit to ${{env.KFUTIL_ARG}} for PR")
183183
const owner = context.repo.owner;
184184
const repo = context.repo.repo;
185185
const baseBranch = 'main';
186-
const newBranch = '${{env.TARGET_REPO_BRANCH}}';
186+
const newBranch = '${{env.KFUTIL_ARG}}';
187187
const response = await github.rest.pulls.create({
188188
owner,
189189
repo,
190-
title: 'New Pull Request - ${{env.TARGET_REPO_BRANCH}}',
190+
title: 'New Pull Request - ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}',
191191
head: newBranch,
192192
base: baseBranch,
193-
body: 'The cert store update from ${{env.TARGET_REPO_BRANCH}} needs to be verified and merged if correct.',
193+
body: 'The cert store update from ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}} needs to be verified and merged if correct.',
194194
});
195-
console.log(`Pull request created: ${{env.TARGET_REPO_BRANCH}} : ${response.data.html_url}`);
195+
console.log(`Pull request created: ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}} : ${response.data.html_url}`);
196196
env:
197197
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}

0 commit comments

Comments
 (0)