Tag on upstream release #1027
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: Tag on upstream release | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
# - cron: "*/5 * * * *" # uncomment for debug (every 5 min) | |
workflow_dispatch: | |
env: | |
UPSTREAM_GITHUB_REPOSITORY: "mxpv/podsync" # Upstream repo | |
jobs: | |
check_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get latest repository tag | |
id: get_latest_tag | |
run: | | |
tag=$(curl --silent https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs/tags | jq -r '.[-1].ref' | awk -F/ '{print $NF}') | |
echo "::debug::git repository tag ${tag}" | |
echo "::set-output name=tag::${tag}" | |
- name: Get upstream version | |
id: get_upstream | |
run: | | |
version=$(curl --silent https://api.github.com/repos/${{ env.UPSTREAM_GITHUB_REPOSITORY }}/tags | jq -r '.[0].name' | sed -e 's/^v//') | |
echo "::debug::get upstream version ${version}" | |
echo "::set-output name=version::${version}" | |
- name: Tag repository with latest upstream version, if needed | |
id: tag_repository | |
if: steps.get_latest_tag.outputs.tag != steps.get_upstream.outputs.version | |
uses: tvdias/github-tagger@ed7350546e3e503b5e942dffd65bc8751a95e49d # v0.0.2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{steps.get_upstream.outputs.version}} | |
- name: Repository dispatch workflow | |
id: dispatch_workflow | |
if: steps.get_latest_tag.outputs.tag != steps.get_upstream.outputs.version | |
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3 | |
with: | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
event-type: new-version |