ci(pr-build): use pr.head.sha as default ref (#209)

This commit is contained in:
Kevin Yu 2023-07-13 19:05:26 +08:00 committed by GitHub
parent acfc1db679
commit 39ddd480f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 10 deletions

View File

@ -33,4 +33,8 @@ jobs:
secrets: inherit
build:
uses: daeuniverse/dae/.github/workflows/seed-build.yml@main
uses: daeuniverse/dae/.github/workflows/seed-build.yml@pr_build_fix
with:
ref: ${{ github.event.pull_request.head.sha }}
pr_build: true
pr_number: ${{ github.event.pull_request.number }}

View File

@ -13,6 +13,18 @@ name: Build
on:
workflow_call:
inputs:
ref:
type: string
required: true
default: ${{ github.ref }}
pr_build:
type: boolean
required: false
default: false
pr_number:
type: number
required: false
jobs:
build:
@ -62,19 +74,19 @@ jobs:
- name: Get the version
id: get_version
env:
REF: ${{ github.ref }}
REF: ${{ inputs.ref }}
PR: pr-${{ inputs.pr_number }}
run: |
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag}
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
commit=$(echo ${REF} | cut -c1-6)
if [[ "${{ inputs.pr_build }}" == "true" ]]; then
count=$(git rev-list --count origin/main..HEAD)
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
version="unstable-${date}.${PR}.r${count}.${commit}"
echo "VERSION=${version}" >> $GITHUB_OUTPUT
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Show workflow information
id: get_filename