Files
Eligio Mariño 7d16500293 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>
2026-05-12 22:18:25 +02:00

29 lines
784 B
JavaScript

module.exports = async ({ core, context, github }) => {
const { NEW_FLUTTER_VERSION } = process.env
if (!NEW_FLUTTER_VERSION) {
core.setFailed('Environment variable NEW_FLUTTER_VERSION is required.')
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.
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${NEW_FLUTTER_VERSION}`,
sha: context.sha,
})
}