batch-example/.gitea/workflows/develop -> build.yml

90 lines
3.7 KiB
YAML
Raw Normal View History

2023-10-21 22:07:10 +00:00
name: build-develop-branch
run-name: ${{ github.actor }} is learning GitHub Actions
on:
push:
branches:
2023-10-23 01:26:40 +00:00
- 'develop/**'
2023-10-21 22:07:10 +00:00
jobs:
build-branch:
runs-on: ubuntu-latest
steps:
# https://github.com/RouxAntoine/checkout/tree/v3.5.4
2023-10-22 10:36:20 +00:00
- uses: http://sigyl.com:3000/actions/checkout@v3.5.4
with:
token: ${{ secrets.BOT_TOKEN }}
2023-10-23 01:26:40 +00:00
fetch-depth: '10'
2023-10-23 13:11:04 +00:00
- env: env
run: printenv
2023-10-23 20:06:46 +00:00
name: get tea
run: |
curl https://dl.gitea.com/tea/0.9.2/tea-0.9.2-linux-386 --output ../tea
chmod +x ./tea
./tea login add -n=this --url=${{ github.server_url}} -t=${{ secrets.BOT_TOKEN }}
2023-10-22 10:36:20 +00:00
- uses: http://sigyl.com:3000/actions/setup-node@v3
2023-10-21 22:07:10 +00:00
with:
node-version: '20'
2023-10-22 10:36:20 +00:00
- uses: http://sigyl.com:3000/actions/batch2yaml@master
2023-10-21 22:07:10 +00:00
with:
action: xml
path: '.'
2023-10-23 01:26:40 +00:00
- run: git fetch
2023-10-23 13:11:04 +00:00
- name: config
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.event.pusher.email }}"
2023-10-21 22:07:10 +00:00
- name: get build branch name
run: |
firstString=${{ github.ref_name }}
2023-10-23 01:26:40 +00:00
secondString="build"
echo ::set-env name=BUILD_BRANCH::${firstString/develop\//"$secondString"\/}
2023-10-23 14:16:50 +00:00
- name: status
run: |
2023-10-23 15:22:49 +00:00
ls
2023-10-23 13:11:04 +00:00
- name: push
2023-10-21 22:07:10 +00:00
run: |
git add -A
2023-10-23 01:26:40 +00:00
git commit -a -m "${{ github.ref_name }} -> ${{ env.BUILD_BRANCH }} "
2023-10-23 14:16:50 +00:00
if [[ $(git branch -r | grep -Fx " origin/${{ env.BUILD_BRANCH }}" | wc -c) -eq 0 ]]; then
git push origin HEAD:${{ env.BUILD_BRANCH }};
2023-10-23 10:03:31 +00:00
else
2023-10-23 14:16:50 +00:00
if [[ $(git diff origin/${{ env.BUILD_BRANCH }} | wc -c) -ne 0 ]]; then
2023-10-23 17:10:37 +00:00
#git rebase -Xtheirs origin/${{ env.BUILD_BRANCH }}
2023-10-23 16:09:18 +00:00
git clone ${{ github.serverUrl }}/${{ github.repository }} ../cloned
git -C ../cloned fetch origin #--depth=1
git -C ../cloned checkout $BUILD_BRANCH || git -C ../cloned checkout -b $BUILD_BRANCH
mv ../cloned/.git ..
rm -rf ../cloned
cp -r . ../cloned
rm -rf ../cloned/.git
mv ../.git ../cloned
mv .git/config ../cloned/.git
rm -r ./*
rm -r .git
mv ../cloned/* .
mv ../cloned/.git .
git add -A
git commit -a -m "${{ github.ref_name }} -> ${{ env.BUILD_BRANCH }} "
2023-10-23 14:16:50 +00:00
git push origin HEAD:${{ env.BUILD_BRANCH }}
else
echo 'no changes so no push'
fi;
2023-10-23 10:03:31 +00:00
fi;
2023-10-23 13:21:34 +00:00
- name: make PR
run: |
2023-10-23 20:06:46 +00:00
../tea login add -n=this --url=${{ github.server_url}} -t=${{ secrets.BOT_TOKEN }}
../tea pr ls -f=base,head -o=csv
2023-10-23 14:16:50 +00:00
if [[ $(./tea pr ls -f=base,head -o=csv | grep "\"master\",\"${{ github.ref_name }}\"" | head -c1 | wc -c) -eq 0 ]]; then
2023-10-23 13:21:34 +00:00
./tea pr c --base=master --head=${{ github.ref_name }} --description="
development pull request
this PR is will been built on [${{ github.ref_name }}](${{ github.serverUrl }}/${{ github.repository }}/src/branch/${{ env.BUILD_BRANCH }})
" -t="WIP: ${{ github.event.head_commit.message }}"
fi
- name: get PR number
run: |
2023-10-23 20:06:46 +00:00
pr=$(../tea pr ls -f=base,head,index -o csv | grep "\"master\",\"${{ github.ref_name }}\"" | tr -d ' ' | tr "," "\n" | head -n 4 | tail -1)
2023-10-23 13:21:34 +00:00
export PR="${pr//[\"\'\`]/}"
echo ::set-env name=PR::$PR
2023-10-21 22:47:52 +00:00
- name: make pull request comment
2023-10-21 22:07:10 +00:00
run: |
2023-10-23 20:06:46 +00:00
../tea c $PR "this branch has been built on [${{ env.BUILD_BRANCH }}](${{ github.serverUrl }}/${{ github.repository }}/src/branch/${{ env.BUILD_BRANCH }})"
2023-10-21 22:07:10 +00:00