Skip to content

Commit

Permalink
Merge pull request #82 from Keyfactor/fix-ref-merge
Browse files Browse the repository at this point in the history
fix branch detection
  • Loading branch information
spbsoluble authored Sep 28, 2023
2 parents 4bf0888 + 377de27 commit f9c4c57
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/update-stores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
if: github.event_name == 'repository_dispatch'
id: set-env-vars-from-payload
run: |
echo "TARGET_REPO_BRANCH=${{ github.event.client_payload.targetRepo }}" | tee -a $GITHUB_ENV
echo "TARGET_REPO_BRANCH=${{ github.event.client_payload.targetRef }}" | tee -a $GITHUB_ENV
echo "KFUTIL_ARG=${{ github.event.client_payload.targetRepo }}" | tee -a $GITHUB_ENV
- name: Check Open PRs for Existing Branch
id: check-branch
Expand All @@ -41,8 +41,8 @@ jobs:
repo,
state: "open"
});
// Filter out ones matching the TARGET_REPO_BRANCH from payload (repository_dispatch) or input (workflow_dispatch)
const filteredData = pulls.data.filter(item => item.head.ref === '${{ env.TARGET_REPO_BRANCH }}');
// Filter out ones matching the KFUTIL_ARG from payload (repository_dispatch) or input (workflow_dispatch)
const filteredData = pulls.data.filter(item => item.head.ref === '${{ env.KFUTIL_ARG }}'); // Look for an existing branch with the orchestrator repo name
const isBranch = (filteredData.length > 0)
if (isBranch) {
const {
Expand All @@ -56,7 +56,7 @@ jobs:
}
console.log(`Branch exists?`)
console.log(filteredData.length > 0)
console.log(`targetRepo: ${{env.TARGET_REPO_BRANCH}}`)
console.log(`targetRepo: ${{env.KFUTIL_ARG}}`)
- name: set env.PR_BRANCH value for jobs
run: |
echo "PR_BRANCH=${{steps.check-branch.outputs.PR_BRANCH}}" | tee -a $GITHUB_ENV
Expand All @@ -71,7 +71,7 @@ jobs:
.github
path: './merge-folder/'
token: ${{ secrets.SDK_SYNC_PAT }}
ref: '${{env.TARGET_REPO_BRANCH}}'
ref: '${{env.KFUTIL_ARG}}'

# If the branch does not exist, first check out the main branch from kfutil.
- name: Check out main
Expand Down Expand Up @@ -155,11 +155,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add: store_types.json --force
message: Update store_types.json for ${{env.TARGET_REPO_BRANCH}}
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}
author_name: Keyfactor
author_email: [email protected]
cwd: './merge-folder/'
new_branch: ${{env.TARGET_REPO_BRANCH}}
new_branch: ${{env.KFUTIL_ARG}}

- name: Add and Commit to existing branch
if: ${{ env.UPDATE_FILE == 'T' && env.PR_BRANCH == 'commit' }}
Expand All @@ -168,7 +168,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add: store_types.json --force
message: Update store_types.json for ${{env.TARGET_REPO_BRANCH}}
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}
author_name: Keyfactor
author_email: [email protected]
cwd: './merge-folder/'
Expand All @@ -178,20 +178,20 @@ jobs:
uses: actions/github-script@v6
with:
script: |
console.log(`Created ${{env.TARGET_REPO_BRANCH}} `)
console.log("Commit to ${{env.TARGET_REPO_BRANCH}} for PR")
console.log(`Created ${{env.KFUTIL_ARG}} `)
console.log("Commit to ${{env.KFUTIL_ARG}} for PR")
const owner = context.repo.owner;
const repo = context.repo.repo;
const baseBranch = 'main';
const newBranch = '${{env.TARGET_REPO_BRANCH}}';
const newBranch = '${{env.KFUTIL_ARG}}';
const response = await github.rest.pulls.create({
owner,
repo,
title: 'New Pull Request - ${{env.TARGET_REPO_BRANCH}}',
title: 'New Pull Request - ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}',
head: newBranch,
base: baseBranch,
body: 'The cert store update from ${{env.TARGET_REPO_BRANCH}} needs to be verified and merged if correct.',
body: 'The cert store update from ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}} needs to be verified and merged if correct.',
});
console.log(`Pull request created: ${{env.TARGET_REPO_BRANCH}} : ${response.data.html_url}`);
console.log(`Pull request created: ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}} : ${response.data.html_url}`);
env:
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}

0 comments on commit f9c4c57

Please sign in to comment.