Skip to content

Instantly share code, notes, and snippets.

@recursivecodes
Created June 23, 2020 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save recursivecodes/a5bb75a2a6b612d10da5c494b4910069 to your computer and use it in GitHub Desktop.
Save recursivecodes/a5bb75a2a6b612d10da5c494b4910069 to your computer and use it in GitHub Desktop.
stop-qa-workflow.yaml
- name: 'Check Running DB Instance'
  run: |
    echo "::set-env name=DB_STATE::$( \
        oci db autonomous-database get \
        --autonomous-database-id ${{ secrets.AUTONOMOUS_DB_OCID }} \
        --query "data.\"lifecycle-state\"" \
        --raw-output \
    )"
- name: 'Stop DB'
  if: ${{env.DB_STATE == 'AVAILABLE'}}
  run: |
    oci db autonomous-database stop \
      --autonomous-database-id  ${{ secrets.AUTONOMOUS_DB_OCID }}
- name: 'Check Running VM Instance'
  run: |
    echo "::set-env name=INSTANCE_OCID::$( \
     oci compute instance list \
     --lifecycle-state RUNNING \
     --compartment-id ${{secrets.VM_COMPARTMENT_OCID}} \
     --display-name ${{env.INSTANCE_NAME}} \
     --query "data [0].id" \
     --raw-output \
    )"
- name: 'Stop VM'
  if: ${{env.INSTANCE_OCID}}
  run: |
    oci compute instance action \
      --action stop \
      --instance-id ${{ env.INSTANCE_OCID }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment