-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.58 KB
/
api_triggered_workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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: Zip Lambda function
run: |
mkdir dist
zip ./dist/minecraftBot.zip ./minecraft-slack-bot/minecraftBot.js
- 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 }}" -var="github_token=${{ secrets.GH_ACTIONS_TOKEN }}"
;;
stop)
terraform apply -auto-approve -var="game_state=stopped" -var="slack_token=${{ secrets.SLACK_BOT_OAUTH_TOKEN }}" -var="github_token=${{ secrets.GH_ACTIONS_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...