Skip to content

Deploy auto archiving script #12

Deploy auto archiving script

Deploy auto archiving script #12

concurrency:
group: deploy-group
name: Deploy auto archiving script
run-name: Deploy auto archiving script
on:
repository_dispatch:
types: [deploy]
workflow_dispatch:
inputs:
commit_message:
description: 手动触发部署流水线的原因:
required: true
default: "deploy auto archiving script manually"
permissions:
contents: write
env:
AUTO_ARCHIVING_SCRIPT_ARCHIVE_URL : "https://github.com/revengenowstudio/rn_issues_auto_archiving/archive/refs/heads/main.zip"
AUTO_ARCHIVING_YML_PATH: "./.github/workflows/AutoArchiving.yml"
COMMIT_MESSAGE: ${{ github.event.inputs.commit_message }}${{ github.event.client_payload.commit_message }}
jobs:
deploy:
name: Deploy auto archiving script
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Pull auto archiving script
# github action 的GITHUB_TOKEN是不提供workflows权限的,所以没法使用GITHUB_TOKEN自动部署流水线yml
run: |
wget $AUTO_ARCHIVING_SCRIPT_ARCHIVE_URL
unzip -q main.zip
cp -rfv ./rn_issues_auto_archiving-main/config ./
cp -rfv ./rn_issues_auto_archiving-main/rn_issue_auto_archiving ./
content=$(<"$AUTO_ARCHIVING_YML_PATH")
updated_content=$(echo "$content" | sed 's/TARGET_BRANCH:[[:space:]]*main/TARGET_BRANCH: master/g')
echo "$updated_content" >"$AUTO_ARCHIVING_YML_PATH"
rm -rf ./rn_issues_auto_archiving-main
rm -f ./main.zip
- name: Push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./config
git add ./rn_issue_auto_archiving
diff=$(git diff --cached)
if [[ -z $diff ]]; then
echo "no file changes"
else
echo "some file changes , pushing changes"
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push origin master
fi