-
Notifications
You must be signed in to change notification settings - Fork 138
53 lines (49 loc) · 1.56 KB
/
trigger-deployment.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
53
name: Trigger Tracecat deployment
on:
push:
branches: main
tags:
- "v*"
workflow_dispatch:
inputs:
build-env:
type: choice
description: Build environment
required: true
options:
- production
- staging
ref:
description: "Branch, commit sha, or tag to deploy"
required: true
jobs:
trigger-deployment:
runs-on: ubuntu-latest
steps:
- name: Set Environment
id: set-env
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "BUILD_ENV=${{ github.event.inputs.build-env }}" >> $GITHUB_ENV
echo "DEPLOY_REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
else
echo "BUILD_ENV=$( [[ '${{ github.ref }}' == 'refs/heads/main' ]] && echo 'staging' || echo 'production' )" >> $GITHUB_ENV
echo "DEPLOY_REF=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Trigger
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const environment = process.env.BUILD_ENV;
const ref = process.env.DEPLOY_REF;
// Send a repository_dispatch event to trigger the Deploy to AWS workflow
github.rest.repos.createDispatchEvent({
owner: 'TracecatHQ',
repo: 'tracecat-deployment',
event_type: 'deploy',
client_payload: {
'build-env': environment,
'ref': ref
}
});