diff --git a/src/pages/docs/packaging-applications/build-servers/github-actions.mdx b/src/pages/docs/packaging-applications/build-servers/github-actions.mdx index e33d3c5fea..f476afebd6 100644 --- a/src/pages/docs/packaging-applications/build-servers/github-actions.mdx +++ b/src/pages/docs/packaging-applications/build-servers/github-actions.mdx @@ -1,7 +1,7 @@ --- layout: src/layouts/Default.astro pubDate: 2023-01-01 -modDate: 2024-11-21 +modDate: 2026-09-15 title: GitHub Actions description: Integrating Octopus Deploy into your GitHub Action workflows icon: fa-brands fa-github @@ -79,8 +79,8 @@ jobs: with: project: 'MyProject' release_number: '1.0.0' - git_ref: ${{ github.ref }} - git_commit: ${{ github.sha }} + git_ref: ${{ github.head_ref || github.ref }} + git_commit: ${{ github.event.pull_request.head.sha || github.sha }} # Action to Deploy a Release - name: Deploy a release in Octopus Deploy 🐙 @@ -96,6 +96,10 @@ jobs: Fizz: Buzz ``` +:::div{.hint} +On a pull request, `github.ref` is `refs/pull//merge` and `github.sha` is the merge commit that GitHub creates for the pull request. That commit does not exist on any branch, so a release pinned to it can fail to deploy later. Use `github.head_ref` and `github.event.pull_request.head.sha` instead, as shown above. Both fall back to the push values on every other event. +::: + ### ✍️ Environment variables | Name | Description | @@ -183,8 +187,8 @@ jobs: with: project: 'MyProject' release_number: '1.0.0' - git_ref: ${{ github.ref }} - git_commit: ${{ github.sha }} + git_ref: ${{ github.head_ref || github.ref }} + git_commit: ${{ github.event.pull_request.head.sha || github.sha }} packages: | HelloPackage:1.0.0 ``` @@ -267,8 +271,8 @@ jobs: with: project: 'MyProject' release_number: '1.0.0' - git_ref: ${{ github.ref }} - git_commit: ${{ github.sha }} + git_ref: ${{ github.head_ref || github.ref }} + git_commit: ${{ github.event.pull_request.head.sha || github.sha }} packages: | HelloPackage:1.0.0 ``` diff --git a/src/pages/docs/projects/version-control/creating-release-from-a-build-server-plug-in.mdx b/src/pages/docs/projects/version-control/creating-release-from-a-build-server-plug-in.mdx index a85a36bed5..79c9a2a103 100644 --- a/src/pages/docs/projects/version-control/creating-release-from-a-build-server-plug-in.mdx +++ b/src/pages/docs/projects/version-control/creating-release-from-a-build-server-plug-in.mdx @@ -1,7 +1,7 @@ --- layout: src/layouts/Default.astro pubDate: 2023-01-01 -modDate: 2026-07-20 +modDate: 2026-09-15 title: Creating releases from a build server plugin on a version-controlled project description: Examples of how to ensure that the right branch is used to create the release when using a build server plugin. navOrder: 45 @@ -51,10 +51,10 @@ ${{ github.head_ref || github.ref }} For *Git Commit*, use ```text -${{ github.event.push.after || github.event.pull_request.head.sha }} +${{ github.event.pull_request.head.sha || github.sha }} ``` -**Note:** this approach doesn't populate the commit details for manually triggered runs. It is recommended that you provide the values for both branch and commit in this case. +On a pull request this resolves to the head of the source branch. On every other event, including manually triggered runs, it falls back to `github.sha`. ## TeamCity