A Github action to keep Another Repo workflow alive after 60days inactive
- Fork this repository
- Create some sercets in your repository(Settings -> Secrets)
REST_TOKEN
: Create a token with the permissionadmin:org, delete:packages, repo, user, workflow, write:packages
in the access token, and then use the value of this token to create a sercet named REST_TOKEN in your repoAPI_ADDRESS
: Use this format:https://api.github.com/repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable
You can replaceworkflow_id
with the workflow file name. For example, you could usemain.yaml
See Docs in https://docs.github.com/cn/rest/reference/actions#enable-a-workflow
- Run github action again,check if the workflow in another repo is enabled.
Notice: This workflow could be disabled by Github after 60 Days inactive.
To wake up mutually,YOU MUST Do above steps in the target repo's workflow again,then add following Github Action after step:
- name: curl
id: enable_workflow
env:
REST_TOKEN: ${{ secrets.REST_TOKEN }}
API_ADDRESS: ${{ secrets.API_ADDRESS }}
run: |
echo "Enable Workflow Start..."
curl -X PUT -H "Authorization: token $REST_TOKEN" "$API_ADDRESS"
echo "Finished"
And cron timer after on:
schedule:
- cron: 00 00 * * *
Run github action and check if this repo workflow is enabled.