Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set AUTOBUILD_VCS_BRANCH for an autobuild package. #28

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ runs:
path: ${{ github.workspace }}/.autobuild-installables
key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.configuration }}-${{ hashFiles('autobuild.xml') }}

- name: Determine branch
id: which-branch
shell: bash
run: |
# in real use, 'git branch -r --contains' should produce a single line,
# but our self-tests can emit more than one
branch="$(git branch -r --contains ${{ steps.sha.outputs.long }} | head -n 1)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an advantage of this git incantation over git rev-parse --abbrev-ref HEAD which has been the standard one that I've included in my shell prompt since time immemorial?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely to report detached HEAD. git branch --contains <hash> reports detached HEAD unless you also supply -r.

echo "branch=${branch#*/}" >> $GITHUB_OUTPUT

- name: Run autobuild
shell: ${{ steps.shell.outputs.shell }}
id: autobuild
Expand All @@ -172,6 +181,7 @@ runs:
AUTOBUILD_GITHUB_TOKEN: ${{ inputs.token }}
AUTOBUILD_INSTALLABLE_CACHE: ${{ github.workspace }}/.autobuild-installables
AUTOBUILD_VARIABLES_FILE: ${{ github.workspace }}/.build-variables/variables
AUTOBUILD_VCS_BRANCH: ${{ steps.which-branch.outputs.branch || github.ref_name }}
AUTOBUILD_VCS_INFO: "true"
BUILD_ID: ${{ inputs.build-id }}
CONFIGURATION: ${{ inputs.configuration }}
Expand Down