-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚙️ config(ci): Factor out custom
github/event
action.
- Loading branch information
1 parent
161e929
commit 419d966
Showing
3 changed files
with
62 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: github/event | ||
description: > | ||
Fetch generic info about GitHub event. | ||
|
||
outputs: | ||
|
||
merge-base: | ||
description: > | ||
The merge base for this event. | ||
value: ${{ steps.merge-base.outputs.sha }} | ||
|
||
runs: | ||
|
||
using: composite | ||
|
||
steps: | ||
|
||
- name: Compute BASE_SHA and HEAD_SHA for push event 📜 | ||
if: github.event_name == 'push' | ||
shell: bash | ||
run: | | ||
BASE_SHA="${{ github.event.before }}" | ||
echo "BASE_SHA=${BASE_SHA}" >> "${GITHUB_ENV}" | ||
HEAD_SHA="${{ github.event.after }}" | ||
echo "HEAD_SHA=${HEAD_SHA}" >> "${GITHUB_ENV}" | ||
|
||
- name: Compute BASE_SHA and HEAD_SHA for pull_request event 📜 | ||
if: github.event_name == 'pull_request' | ||
shell: bash | ||
run: | | ||
BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
echo "BASE_SHA=${BASE_SHA}" >> "${GITHUB_ENV}" | ||
HEAD_SHA="${{ github.event.pull_request.head.sha }}" | ||
echo "HEAD_SHA=${HEAD_SHA}" >> "${GITHUB_ENV}" | ||
|
||
- name: Compute BASE_SHA and HEAD_SHA for merge_group event 📜 | ||
if: github.event_name == 'merge_group' | ||
shell: bash | ||
run: | | ||
BASE_SHA="${{ github.event.merge_group.base_sha }}" | ||
echo "BASE_SHA=${BASE_SHA}" >> "${GITHUB_ENV}" | ||
HEAD_SHA="${{ github.event.merge_group.head_sha }}" | ||
echo "HEAD_SHA=${HEAD_SHA}" >> "${GITHUB_ENV}" | ||
|
||
- name: Compute MERGE_BASE 🌱 | ||
id: merge-base | ||
env: | ||
BASE_SHA: ${{ env.BASE_SHA }} | ||
HEAD_SHA: ${{ env.HEAD_SHA }} | ||
shell: bash | ||
run: | | ||
FIRST_NEW_COMMIT="$(git log "${BASE_SHA}..${HEAD_SHA}" --pretty=format:%H | tail -1)" | ||
MERGE_BASE="$(git rev-parse "${FIRST_NEW_COMMIT}~")" | ||
echo "sha=${MERGE_BASE}" >> "${GITHUB_OUTPUT}" |
This file contains 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
This file contains 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