GH Action: update-app-version #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync appVersion | |
on: | |
push: | |
branches: | |
- SCALRCORE-27249 | |
workflow_dispatch: | |
inputs: | |
app_version: | |
description: TODO | |
required: true | |
type: string | |
env: | |
PR_BRANCH: 'actions/sync-app-version-${{ github.ref_name }}' | |
jobs: | |
sync-app-version: | |
name: Sync appVersion | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update appVersion | |
id: update | |
uses: ./.github/actions/update-app-version | |
with: | |
app_version: ${{inputs.app_version}} | |
- name: Commit Changes | |
shell: bash | |
run: |- | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b $PR_BRANCH | |
git status | |
git add . | |
git commit -m "Release: ${{steps.update.outputs.version}}" | |
git push origin $PR_BRANCH --force | |
- name: 'Create Pull Request' | |
uses: 'actions/github-script@v6' | |
with: | |
script: |- | |
const tag = "v" + process.env.NEW_VERSION; | |
try { | |
const listResponse = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: "open", | |
head: context.repo.owner + ":" + process.env.PR_BRANCH, | |
base: process.env.GITHUB_REF_NAME, | |
}); | |
core.isDebug() && console.log(listResponse); | |
if (!listResponse.data.length) { | |
const createResponse = await github.rest.pulls.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: "Release: " + tag, | |
body: process.env.RELEASE_NOTES, | |
head: process.env.PR_BRANCH, | |
base: process.env.GITHUB_REF_NAME, | |
}); | |
core.info( | |
`Created PR #${createResponse.data.number} at ${createResponse.data.html_url}` | |
); | |
} else { | |
const updateResponse = await github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: listResponse.data[0].number, | |
title: "Release: " + tag, | |
body: process.env.RELEASE_NOTES, | |
}); | |
core.info( | |
`Updated PR #${updateResponse.data.number} at ${updateResponse.data.html_url}` | |
); | |
} | |
} catch (err) { | |
console.error(err); | |
core.setFailed(`Failed to create pull request: ${err}`); | |
} |