Poll Hyperion.NG (Pre-)releases #145
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: Poll Hyperion.NG (Pre-)releases | |
on: | |
schedule: | |
# Runs at 00:00 UTC everyday | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
local_tag: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.read-tag.outputs.value }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read current tag from CI workflow | |
id: read-tag | |
run: echo value=$(yq -r .jobs.build_hyperion_ng.steps[0].with.ref ./.github/workflows/build.yml) >> $GITHUB_OUTPUT | |
- name: Print out gathered tag | |
run: echo "Current tag=${{ steps.read-tag.outputs.value }}" | |
remote_tag: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.read-tag.outputs.value }} | |
steps: | |
- name: Checkout Hyperion.NG repo | |
uses: actions/checkout@v3 | |
with: | |
repository: hyperion-project/hyperion.ng | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Get latest tag of Hyperion.NG | |
id: read-tag | |
run: echo value=$(git describe --tags --abbrev=0) >> $GITHUB_OUTPUT | |
- name: Print out gathered tag | |
run: echo "Current tag=${{ steps.read-tag.outputs.value }}" | |
create_pull_request: | |
runs-on: ubuntu-latest | |
needs: [local_tag, remote_tag] | |
if: ${{ needs.local_tag.outputs.tag != needs.remote_tag.outputs.tag }} | |
steps: | |
- name: Assemble PR branch name | |
run: echo "pr_branch=update_daemon/${{ needs.remote_tag.outputs.tag }}" >> $GITHUB_ENV | |
- name: Check if PR already exists by attempting to checkout branch | |
continue-on-error: true | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.pr_branch }} | |
- name: Check if PR branch cloned | |
run: | | |
sh -c 'if [[ -f package.json ]]; then echo "PR already exists"; exit 1; fi' | |
- name: Clone master branch | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
fetch-depth: 0 | |
- name: Inject latest tag into CI workflow file | |
run: sed -i 's/${{ needs.local_tag.outputs.tag }}/${{ needs.remote_tag.outputs.tag }}/' ./.github/workflows/build.yml | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
add-paths: .github/workflows/build.yml | |
title: "[Daemon] Bump Hyperion.NG to ${{ needs.remote_tag.outputs.tag }}" | |
commit-message: "[Daemon] Bump Hyperion.NG to ${{ needs.remote_tag.outputs.tag }}" | |
branch: ${{ env.pr_branch }} | |
delete-branch: true | |