add push-master workflow #9
Workflow file for this run
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 workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: Master Rebase | |
on: | |
push: | |
branches: [ "test-ci-push" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
cache: false | |
- name: Ensure HEAD~1 Same With Master | |
run: | | |
set -x | |
git fetch origin master | |
master_commit=$(git rev-parse origin/master) | |
head_parent_commit=$(git rev-parse HEAD~1) | |
if [[ $master_commit != $head_parent_commit ]];then | |
echo "HEAD~1 differs with origin/master" >&2 | |
exit 1 | |
fi | |
- name: Run Git Hooks | |
run: | | |
set -x | |
echo 'before' | |
cat cmd/xgo/version.go | |
go run ./script/git-hooks pre-commit --amend --no-commit | |
git status | |
echo 'after' | |
cat cmd/xgo/version.go | |
git add -A | |
git config user.email "$(git log --format=%ae -n1 HEAD)" | |
git config user.name "$(git log --format=%an -n1 HEAD)" | |
git commit --amend --no-edit --no-verify | |
git status | |
git push origin HEAD:"$(git branch --show-current)-test" -f | |
- name: Check | |
run: git status |