JOJ3/.gitea/workflows/build.yaml
zzjc1234 1a9c773651
All checks were successful
build / build (push) Successful in 1m23s
build / trigger-build-image (push) Has been skipped
build / triger-update-ci (push) Successful in 22s
build / build (pull_request) Successful in 1m42s
build / trigger-build-image (pull_request) Has been skipped
build / triger-update-ci (pull_request) Successful in 12s
feat: update workflow
2024-10-10 16:09:14 +08:00

118 lines
4.5 KiB
YAML

---
name: build
on:
- push
- pull_request
jobs:
build:
container:
image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ci-test
volumes:
- /home/actions/.ssh:/root/.ssh
steps:
- name: Check out repository code
uses: https://gitea.com/BoYanZh/checkout@focs
- name: Setup Go 1.23.1
run: |
echo "PATH=$PATH:/usr/local/go/bin:/root/go/bin" >> $GITHUB_ENV
- name: Display Go version
run: go version
- name: Prepare
run: |
chown -R root:root /root/.ssh
- name: Setup Joint-Teapot
run: |
if [ -f /master_hash.txt ]; then
local_hash=$(cat /master_hash.txt)
else
local_hash=""
fi
remote_hash=$(git ls-remote https://ghp.ci/https://github.com/BoYanZh/Joint-Teapot | grep master | awk '{print $1}')
echo "Local hash: $local_hash"
echo "Remote hash: $remote_hash"
if [ "$local_hash" != "$remote_hash" ]; then
echo "Hashes are different, updating Joint-Teapot..."
pip install git+https://ghp.ci/https://github.com/BoYanZh/Joint-Teapot
else
echo "Hashes are the same, no update required."
fi
- name: Lint
run: make lint
- name: Build
run: make build
- name: Version
run: ./build/joj3 -version
- name: Test
run: |
make prepare-test
make ci-test
trigger-build-image:
container:
image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest
volumes:
- /home/actions/.ssh:/root/.ssh
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Set up Git
run: |
git config --global user.name "gitea-actions[bot]"
git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com"
chown -R root:root /root/.ssh
- name: Clone, Commit and Push
shell: bash
run: |
git clone ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/runner-images.git runner-images
cd runner-images
git submodule update --init --remote --force
git add -A
if echo "${{ github.event.head_commit.message }}" | grep -q "force build"; then
git commit --allow-empty -m "chore: trigger force build gitea actions by JOJ3"
else
git commit --allow-empty -m "chore: trigger gitea actions by JOJ3"
fi
git push
triger-update-ci:
container:
image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ci-test
volumes:
- /home/actions/.ssh:/root/.ssh
needs: build
steps:
- name: Check update
run: |
if [ -f /master_hash.txt ]; then
local_hash=$(cat /master_hash.txt)
else
local_hash=""
fi
remote_hash=$(git ls-remote https://ghp.ci/https://github.com/BoYanZh/Joint-Teapot | grep master | awk '{print $1}')
echo "Local hash: $local_hash"
echo "Remote hash: $remote_hash"
if [ "$local_hash" != "$remote_hash" ]; then
echo "Hashes are different, updating Joint-Teapot..."
else
echo "Hashes are the same, no update required."
exit 0
fi
- name: Set up Git
run: |
git config --global user.name "gitea-actions[bot]"
git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com"
chown -R root:root /root/.ssh
- name: Clone, Commit and Push
shell: bash
run: |
git clone ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/runner-images.git runner-images
cd runner-images
git checkout ci-test
make build
make push