custom_event #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: API Triggered Workflow | |
on: | |
repository_dispatch: | |
types: [custom_event] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Initialize Terraform | |
working-directory: ./terraform | |
run: terraform init | |
- name: Execute Terraform based on payload | |
working-directory: ./terraform | |
run: | | |
case "${{ github.event.client_payload.action }}" in | |
start) | |
terraform apply -auto-approve -var="game_state=running" -var="slack_token=${{ secrets.SLACK_BOT_OAUTH_TOKEN }}" | |
;; | |
stop) | |
terraform apply -auto-approve -var="game_state=stopped" -var="slack_token=${{ secrets.SLACK_BOT_OAUTH_TOKEN }}" | |
;; | |
status) | |
terraform output -json | |
;; | |
*) | |
echo "Unknown action: ${{ github.event.client_payload.action }}" | |
exit 1 | |
;; | |
esac | |
# - name: Print the payload | |
# run: echo '${{ toJson(github.event.client_payload) }}' | jq . | |
# Add more steps as needed... |