MergeUpstream #2398
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 is free software, lisence use MIT. | |
# | |
# Copyright (C) 2019 KFERMercer <[email protected]> | |
# | |
# <https://github.com/KFERMercer/OpenWrt-CI> | |
# | |
name: MergeUpstream | |
on: | |
workflow_dispatch: # 手动触发 | |
schedule: | |
- cron: 00 */12 * * * | |
# push: | |
# branches: | |
# - master | |
watch: | |
types: [started] | |
jobs: | |
merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
with: | |
ref: master | |
fetch-depth: 0 | |
lfs: true | |
- name: Set git identity | |
run : | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git config pull.ff true | |
- name: Load upstream commits | |
run: git pull https://github.com/immortalwrt/packages.git master --log --no-commit | |
- name: Apply commit changes | |
run: | | |
if [ -f ./.git/MERGE_MSG ]; then | |
mkdir ./tmp && cp ./.git/MERGE_MSG ./tmp/message | |
sed -i "1c [bot] AutoMerging: merge all upstream's changes:" ./tmp/message | |
sed -i '/^\#.*/d' ./tmp/message | |
git commit --file="./tmp/message" | |
else | |
echo "There is no merge commits." | |
fi | |
- name: Push Commits | |
env: | |
DOWNSTREAM_BRANCH: master | |
run: git push origin $DOWNSTREAM_BRANCH | |
Cleanup-Old-Artifacts: | |
needs: [merge] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cleanup Old Action Artifacts | |
uses: kolpav/purge-artifacts-action@master | |
with: | |
token: ${{ github.token }} | |
expire-in: 7d | |
Cleanup-Workflow-Runs: | |
needs: Cleanup-Old-Artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cleanup Workflow Runs | |
uses: GitRML/delete-workflow-runs@main | |
with: | |
token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
retain_days: 7 |