mirror of
https://github.com/gmeligio/flutter-docker-image.git
synced 2026-05-24 12:30:34 +00:00
ci: make workflows fork-PR friendly by removing vars.FLUTTER_VERSION (#447)
Repository variables are not exposed to PRs from forks, so jobs that reference vars.FLUTTER_VERSION at the container.image level fail to resolve and the workflow template errors out before any step runs. Replace it with a setup job that reads the latest published release tag via the GitHub API using the read-only GITHUB_TOKEN, which is available in fork-PR contexts. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+14
-9
@@ -1,20 +1,25 @@
|
||||
module.exports = async ({ core, context, github }) => {
|
||||
const { OLD_FLUTTER_VERSION, NEW_FLUTTER_VERSION } = process.env
|
||||
|
||||
if (!OLD_FLUTTER_VERSION) {
|
||||
core.setFailed('Environment variable OLD_FLUTTER_VERSION is required.')
|
||||
}
|
||||
const { NEW_FLUTTER_VERSION } = process.env
|
||||
|
||||
if (!NEW_FLUTTER_VERSION) {
|
||||
core.setFailed('Environment variable NEW_FLUTTER_VERSION is required.')
|
||||
}
|
||||
|
||||
if (OLD_FLUTTER_VERSION === NEW_FLUTTER_VERSION) {
|
||||
return
|
||||
}
|
||||
|
||||
// If a tag for this version already exists, do nothing.
|
||||
try {
|
||||
await github.rest.git.getRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `tags/${NEW_FLUTTER_VERSION}`,
|
||||
})
|
||||
return
|
||||
} catch (error) {
|
||||
if (error.status !== 404) throw error
|
||||
}
|
||||
|
||||
// Create a git tag using the GitHub API instead of the git client to skip SSH/GPG key setup.
|
||||
github.rest.git.createRef({
|
||||
await github.rest.git.createRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `refs/tags/${NEW_FLUTTER_VERSION}`,
|
||||
|
||||
Reference in New Issue
Block a user