Hello guys, I'm trying to use codespace as a remote server and needed to turn on/off codespace at certain time.
- There is a codespace created that you want to automate. (ex, do some scheduled jobs)
- You have already set a cronjob or a scheduled job in the codespace
- Through this action, you only turn on/off at the right timing to make above job work on time.
- You should have github tokens with permissions for codespace.
- You should have a codespace already created. (because it just turns on & off existing one)
- cron: make this 1~2 minutes earlier before your "real cron job" in codespace starts
CODESPACE_NAME: name of your target codespace. ex)curious-fox-wr3249sfop3WAIT_SECONDS: seconds to wait before stopping the codespace. I think it should be long enough to start the codespace + do your work in codespace. Calculate it so that your monthly usage minutes does not exceed the free tier.
name: Codespace Scheduler
on:
schedule:
- cron: '*/5 * * * *'
workflow_dispatch:
jobs:
codespace_scheduler:
runs-on: ubuntu-latest
steps:
- name: Codespace Scheduler
uses: ud803/[email protected]
env:
GITHUB_AUTH: ${{ secrets.YOUR_TOKEN_NAME_WITH_PERMISSION_TO_CODESPACE }}
with:
CODESPACE_NAME: "your-codespace-name"
WAIT_SECONDS: 30