Update latest #31
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: Update latest | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: | |
- Base Image | |
types: | |
- completed | |
jobs: | |
update-latest: | |
name: Rebuild release images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Find latest tag | |
uses: actions/github-script@v7 | |
with: | |
# need different token, RELEASE_TOKEN belongs to digineobot | |
github-token: ${{ secrets.RELEASE_TOKEN }} | |
script: | | |
const { data: { tag_name: releaseTag } } = await github.rest.repos.getLatestRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}) | |
console.log(`latest release tag name: ${releaseTag}`) | |
const { data: { object: { sha: releaseRef } } } = await github.rest.git.getRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `tags/${releaseTag}`, | |
}) | |
console.log(`latest release commit: ${releaseRef}`) | |
const { data: { object: { sha: masterRef } } } = await github.rest.git.getRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'heads/master', | |
}) | |
console.log(`master release commit: ${masterRef}`) | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'release.yml', | |
ref: releaseTag, | |
inputs: { | |
goreleaser: false, | |
releaseType: 'release', | |
} | |
}) | |
console.log(`triggered release for ${releaseTag} (${releaseRef})`) | |
if (releaseRef !== masterRef) { | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'release.yml', | |
ref: 'master', | |
inputs: { | |
goreleaser: false, | |
releaseType: 'dev', | |
} | |
}) | |
console.log(`triggered dev-release for master (${masterRef})`) | |
} |