Make the ESPHome GitHub App optional in publish-draft-release - #183
Merged
Merged
Conversation
Fall back to the default GITHUB_TOKEN when the App is not configured, so template-generated and other outside consumer repositories can use this reusable workflow. The App is still used when configured so that publishing emits a downstream release: published event; the fallback path publishes with GITHUB_TOKEN, which does not emit that event, so consumers must trigger off workflow_run instead. Also make the deployment environment an optional input defaulting to release.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
publish-draft-release.ymlcurrently hard-requires the ESPHome GitHub App (vars.ESPHOME_GITHUB_APP_CLIENT_ID/secrets.ESPHOME_GITHUB_APP_PRIVATE_KEY).esphome-project-templateis a GitHub template repo that outside people generate into their own accounts, where the App does not exist. The rest of the template's release/build/draft pipeline runs entirely on the defaultGITHUB_TOKEN; this publish step was the only App dependency. This brings the shared reusable to parity so the template, and any other outside consumer, can eventually justuses:it.Changes
ESPHOME_GITHUB_APP_PRIVATE_KEYsecret is nowrequired: false.permissions: contents: write(was{}), which is what lets the fallbackgithub.tokenread the draft, replace its*.manifest.jsonassets and publish it. When the App token is used,github.tokensimply goes unused.Generate a tokenstep is gated onif: ${{ vars.ESPHOME_GITHUB_APP_CLIENT_ID != '' }}, so it is skipped when the App is not configured.GH_TOKENnow resolves to${{ steps.generate-token.outputs.token || github.token }}; a skipped step's output is empty, selectinggithub.tokenon the fallback path.environmentis now an optional input defaulting torelease, so org repos keep their protection rules while outside repos can pass an empty string to opt out.GITHUB_TOKENdoes NOT emit a downstreamrelease: publishedevent (GitHub's anti-recursion rule), so consumers that rely on that event must trigger offworkflow_runof their Release workflow on the fallback path instead.esphome-project-templatedoes exactly this.publish-draft-release.ymlis not smoke-tested byci.yml/ci-draft-release.yml(it needs a live draft plus a real publish), so this relies on static checks (yamllint) and review. Existing org callers are unaffected: the newenvironmentinput defaults toreleaseand the now-optional secret is still supplied.