diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 661d0e1..06ed969 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,4 +57,4 @@ jobs: - name: Release Plz uses: MarcoIeni/release-plz-action@v0.5 env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/workspace/gh-workflow-gen/build.rs b/workspace/gh-workflow-gen/build.rs index 1d2b524..e6adaee 100644 --- a/workspace/gh-workflow-gen/build.rs +++ b/workspace/gh-workflow-gen/build.rs @@ -51,10 +51,7 @@ fn main() { .permissions(Permissions::read()) .on(event) .add_job("build", job) - .add_job( - "release", - release.add_env(("GITHUB_TOKEN", "${{ secrets.GH_TOKEN }}")), - ) + .add_job("release", release.add_github_token()) .generate() .unwrap(); } diff --git a/workspace/gh-workflow/src/workflow.rs b/workspace/gh-workflow/src/workflow.rs index 8aef6ad..2896e14 100644 --- a/workspace/gh-workflow/src/workflow.rs +++ b/workspace/gh-workflow/src/workflow.rs @@ -99,6 +99,12 @@ impl Workflow { self.env = Some(env); self } + + /// Add the default token created by GitHub to authenticate on behalf of GitHub Actions. + /// See: + pub fn add_github_token(self) -> Self { + self.add_env(("GITHUB_TOKEN", "${{ secrets.GITHUB_TOKEN }}")) + } } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] @@ -191,6 +197,12 @@ impl Job { self.env = Some(env); self } + + /// Add the default token created by GitHub to authenticate on behalf of GitHub Actions. + /// See: + pub fn add_github_token(self) -> Self { + self.add_env(("GITHUB_TOKEN", "${{ secrets.GITHUB_TOKEN }}")) + } } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]