enable region

This commit is contained in:
zizifn
2022-04-08 22:38:31 +08:00
committed by zizifn
parent 829506918a
commit c705d26ace

View File

@@ -18,45 +18,46 @@ on:
default: "" default: ""
jobs: jobs:
jobenv: # jobenv:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
environment: ${{ github.event.inputs.env }} # environment: ${{ github.event.inputs.env }}
env: # Or as an environment variable # env: # Or as an environment variable
APP_NAME: ${{ secrets.APP_NAME }} # APP_NAME: ${{ secrets.APP_NAME }}
outputs: # outputs:
actions: ${{ github.event.inputs.actions || 'deploy'}} # actions: ${{ github.event.inputs.actions || 'deploy'}}
herokuAppName: ${{ github.event.inputs.heroku-app-name }} # herokuAppName: ${{ github.event.inputs.heroku-app-name }}
test111: ${{ github.event.inputs.env }} # todo # test111: ${{ github.event.inputs.env }} # todo
steps: # steps:
- id: herokuAppName # TODO check atcion doc for usage # - id: herokuAppName # TODO check atcion doc for usage
# if: ${{ github.event.inputs.actions == 'start'}} # # 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 || secrets.APP_NAME }}"
run: echo ::set-output name=name::${{ github.event.inputs.heroku-app-name }} # run: echo ::set-output name=name::${{ github.event.inputs.heroku-app-name }}
- id: isDeployHeroku # TODO check atcion doc for usage # - id: isDeployHeroku # TODO check atcion doc for usage
# if: ${{ github.event.inputs.actions == 'start'}} # # if: ${{ github.event.inputs.actions == 'start'}}
run: echo "::set-output name=action::false" # run: echo "::set-output name=action::false"
output-jobenv: # output-jobenv:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
needs: jobenv # needs: jobenv
steps: # steps:
# - id: test-env # # - id: test-env
# if: ${{ env.test-env }} # # if: ${{ env.test-env }}
# run: echo needs.jobenv.outputs.herokuAppName is ${{needs.jobenv.outputs.herokuAppName}} # # run: echo needs.jobenv.outputs.herokuAppName is ${{needs.jobenv.outputs.herokuAppName}}
- run: echo test111 is ${{needs.jobenv.outputs.test111}} # - run: echo test111 is ${{needs.jobenv.outputs.test111}}
# - run: echo ${{needs.jobenv.outputs.herokuAppName}} | sed 's/./& /g' # # - run: echo ${{needs.jobenv.outputs.herokuAppName}} | sed 's/./& /g'
heroku-deploy: heroku-deploy:
needs: jobenv
if: ${{ needs.jobenv.outputs.actions == 'deploy' || needs.jobenv.outputs.actions == ''}} if: ${{ needs.jobenv.outputs.actions == 'deploy' || needs.jobenv.outputs.actions == ''}}
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: ${{ github.event.inputs.env }} environment: ${{ github.event.inputs.env }}
env: # Or as an environment variable
APP_NAME: ${{ github.event.inputs.heroku-app-name || secrets.APP_NAME }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
with: with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{needs.jobenv.outputs.herokuAppName}} #Must be unique in Heroku heroku_app_name: ${{ env.APP_NAME }} #Must be unique in Heroku
heroku_email: ${{secrets.EMAIL}} heroku_email: ${{secrets.EMAIL}}
usedocker: true usedocker: true
region: ${{github.event.inputs.heroku-region || 'us'}} region: ${{github.event.inputs.heroku-region || 'us'}}
@@ -69,10 +70,11 @@ jobs:
NODE_ENV: production NODE_ENV: production
SECRET_KEY: ${{ secrets.MY_SECRET_KEY }} SECRET_KEY: ${{ secrets.MY_SECRET_KEY }}
stop-start-destroy: stop-start-destroy:
needs: jobenv
if: ${{ needs.jobenv.outputs.actions == 'start' || needs.jobenv.outputs.actions == 'stop' || needs.jobenv.outputs.actions == 'destroy' }} if: ${{ needs.jobenv.outputs.actions == 'start' || needs.jobenv.outputs.actions == 'stop' || needs.jobenv.outputs.actions == 'destroy' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: ${{ github.event.inputs.env }} environment: ${{ github.event.inputs.env }}
env: # Or as an environment variable
APP_NAME: ${{ github.event.inputs.heroku-app-name || secrets.APP_NAME }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.7.8 # This is the action - uses: akhileshns/heroku-deploy@v3.7.8 # This is the action
@@ -82,7 +84,7 @@ jobs:
justlogin: true justlogin: true
- run: | - run: |
echo action is ${{ needs.jobenv.outputs.actions }} 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 }} == 'stop' ]]; then heroku ps:scale web=0 -a ${{env.APP_NAME}} && echo "stop"; fi
if [[ ${{ needs.jobenv.outputs.actions }} == 'start' ]]; then heroku ps:scale web=1 -a ${{needs.jobenv.outputs.herokuAppName}} && echo "start"; fi if [[ ${{ needs.jobenv.outputs.actions }} == 'start' ]]; then heroku ps:scale web=1 -a ${{env.APP_NAME}} && echo "start"; fi
heroku ps -a ${{needs.jobenv.outputs.herokuAppName}} heroku ps -a ${{env.APP_NAME}}
if [[ ${{ needs.jobenv.outputs.actions }} == 'destroy' ]]; then heroku apps:destroy -a ${{needs.jobenv.outputs.herokuAppName}} --confirm ${{needs.jobenv.outputs.herokuAppName}} && echo "destroy app"; fi if [[ ${{ needs.jobenv.outputs.actions }} == 'destroy' ]]; then heroku apps:destroy -a ${{env.APP_NAME}} --confirm ${{env.APP_NAME}} && echo "destroy app"; fi