Skip to content

Commit

Permalink
try octokit
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanphan committed Jan 3, 2025
1 parent f67607a commit 05a78ce
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/deploy-program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,34 +268,26 @@ jobs:
if: github.event.inputs.dry_run == 'false'
with:
script: |
const refData = await github.rest.git.getRef({
const octokit = github.getOctokit('${{ secrets.GH_TAGGER_TOKEN }}');
const refData = await octokit.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ inputs.git_ref }}',
headers: {
authorization: 'token ${{ secrets.GH_TAGGER_TOKEN }}'
}
ref: 'tags/${{ inputs.git_ref }}'
});
if (refData.status !== 200) {
throw new Error('Failed to fetch existing tag');
}
await github.rest.git.createRef({
await octokit.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ needs.check_tag.outputs.program }}-${{ inputs.cluster }}',
sha: refData.data.object.sha,
headers: {
authorization: 'token ${{ secrets.GH_TAGGER_TOKEN }}'
}
sha: refData.data.object.sha
}).catch(err => {
if (err.status !== 422) throw err;
github.rest.git.updateRef({
octokit.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ needs.check_tag.outputs.program }}-${{ inputs.cluster }}',
sha: refData.data.object.sha,
headers: {
authorization: 'token ${{ secrets.GH_TAGGER_TOKEN }}'
}
ref: 'tags/${{ needs.check_tag.outputs.program }}-${{ inputs.cluster }}',
sha: refData.data.object.sha
});
})

0 comments on commit 05a78ce

Please sign in to comment.