mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
90 lines
4.1 KiB
YAML
90 lines
4.1 KiB
YAML
name: heroku-deploy-stop-start
|
||
|
||
on:
|
||
workflow_dispatch:
|
||
inputs:
|
||
actions:
|
||
description: "action: deploy/stop/start/destroy"
|
||
default: "deploy"
|
||
heroku-region:
|
||
description: "us or eu. 如果你的app已经创建,切换到不同的region,需要先删除app"
|
||
default: "us"
|
||
heroku-app-name:
|
||
description: "可选,如果输入,则会覆盖 Secrets 里面配置的 APP_NAME"
|
||
default: ""
|
||
required: false
|
||
env:
|
||
description: "environment: Input the name of Environment. If left blank, the main secrets setting will be used by default."
|
||
default: ""
|
||
|
||
jobs:
|
||
jobenv:
|
||
runs-on: ubuntu-latest
|
||
environment: ${{ github.event.inputs.env}}
|
||
env: # Or as an environment variable
|
||
APP_NAME: ${{ secrets.APP_NAME }}
|
||
outputs:
|
||
actions: ${{ github.event.inputs.actions || 'deploy'}}
|
||
herokuAppName: ${{ steps.herokuAppName.outputs.name }}
|
||
test111: ${{ github.event.inputs.env }} # todo
|
||
steps:
|
||
- id: herokuAppName # TODO check atcion doc for usage
|
||
# if: ${{ github.event.inputs.actions == 'start'}}
|
||
# run: echo "::set-output name=name::${{ github.event.inputs.heroku-app-name || secrets.APP_NAME }}"
|
||
run: echo "::set-output name=name::${{ github.event.inputs.heroku-app-name || env.APP_NAME }}"
|
||
- id: isDeployHeroku # TODO check atcion doc for usage
|
||
# if: ${{ github.event.inputs.actions == 'start'}}
|
||
run: echo "::set-output name=action::false"
|
||
output-jobenv:
|
||
runs-on: ubuntu-latest
|
||
needs: jobenv
|
||
steps:
|
||
# - id: test-env
|
||
# if: ${{ env.test-env }}
|
||
# run: echo needs.jobenv.outputs.herokuAppName is ${{needs.jobenv.outputs.herokuAppName}}
|
||
- run: echo test111 is ${{needs.jobenv.outputs.test111}}
|
||
- run: |
|
||
echo output first 4 letter herokuAppName $(echo ${{needs.jobenv.outputs.herokuAppName}} | cut -c 1-4 | sed 's/./& /g')
|
||
|
||
|
||
heroku-deploy:
|
||
needs: jobenv
|
||
if: ${{ needs.jobenv.outputs.actions == 'deploy' || needs.jobenv.outputs.actions == ''}}
|
||
runs-on: ubuntu-latest
|
||
environment: ${{ github.event.inputs.env }}
|
||
steps:
|
||
- uses: actions/checkout@v2
|
||
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
|
||
with:
|
||
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
|
||
heroku_app_name: ${{needs.jobenv.outputs.herokuAppName}} #Must be unique in Heroku
|
||
heroku_email: ${{secrets.EMAIL}}
|
||
usedocker: true
|
||
region: ${{github.event.inputs.heroku-region || 'us'}}
|
||
# docker_build_args: |
|
||
# HD_UUID
|
||
env:
|
||
# 这是为了heroku,注意前缀有个HD,这是为了告诉heroku-deploy,这些变量需要传入到 container 中。
|
||
HD_UUID: ${{ secrets.HEROKU_V2RAY_UUID }} # UUID for v2ray user, 为了安全,一定要放入 github action token 中
|
||
HD_TUNNEL_TOKEN: ${{ secrets.HEROKU_TUNNEL_TOKEN }} # token for cloudflared tunnel
|
||
NODE_ENV: production
|
||
SECRET_KEY: ${{ secrets.MY_SECRET_KEY }}
|
||
stop-start-destroy:
|
||
needs: jobenv
|
||
if: ${{ needs.jobenv.outputs.actions == 'start' || needs.jobenv.outputs.actions == 'stop' || needs.jobenv.outputs.actions == 'destroy' }}
|
||
runs-on: ubuntu-latest
|
||
environment: ${{ github.event.inputs.env }}
|
||
steps:
|
||
- uses: actions/checkout@v2
|
||
- uses: akhileshns/heroku-deploy@v3.7.8 # This is the action
|
||
with:
|
||
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
|
||
heroku_email: ${{secrets.EMAIL}}
|
||
justlogin: true
|
||
- run: |
|
||
echo action is ${{ needs.jobenv.outputs.actions }}
|
||
if [[ ${{ needs.jobenv.outputs.actions }} == 'stop' ]]; then heroku ps:scale web=0 -a ${{needs.jobenv.outputs.herokuAppName}} && echo "stop"; fi
|
||
if [[ ${{ needs.jobenv.outputs.actions }} == 'start' ]]; then heroku ps:scale web=1 -a ${{needs.jobenv.outputs.herokuAppName}} && echo "start"; fi
|
||
heroku ps -a ${{needs.jobenv.outputs.herokuAppName}}
|
||
if [[ ${{ needs.jobenv.outputs.actions }} == 'destroy' ]]; then heroku apps:destroy -a ${{needs.jobenv.outputs.herokuAppName}} --confirm ${{needs.jobenv.outputs.herokuAppName}} && echo "destroy app"; fi
|