forked from jonhoo/wewerewondering
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (77 loc) · 3.08 KB
/
terraform-apply.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# This template is pre-configured to create an applyable run in Terraform Cloud.
# If the plan phase is successful, the run will be applied for the specified workspace.
#
# This workflow is configured to trigger when a push against your `main` branch occurs,
# **IF** the set paths contain files that have changed.
#
# Copied from
# https://github.com/hashicorp/tfc-workflows-github/blob/4e91ea58dde1e255e6cecdfd7a19c5f395538393/workflow-templates/terraform-cloud.apply-run.workflow.yml
---
name: Terraform Cloud Apply Run
on:
push:
branches:
- main
## RECOMMENDED: Specify to only run this workflow file when terraform configuration has changed.
# NOTE: not setting this since we want the client/server artifacts to be
# re-deployed when re-built.
# paths:
# - <<INPUT REQUIRED>> ## Example: 'terraform/**.tf'
## RECOMMENDED: Limit apply runs job / workflow to a single concurrency group at a time.
## link: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency: production
## Add shared Environment Variables across jobs here ##
env:
NODE_VERSION: 18
TF_CLOUD_ORGANIZATION: ${{ vars.TF_CLOUD_ORGANIZATION }}
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
TF_WORKSPACE: ${{ vars.TF_WORKSPACE }}
CONFIG_DIRECTORY: "./infra"
## Additional env variables
# TF_LOG: DEBUG ## Helpful for troubleshooting
# TF_MAX_TIMEOUT: "30m" ## If you wish to override the default "1h"
jobs:
terraform-cloud-apply-run:
name: "Terraform Apply"
runs-on: ubuntu-latest
environment: prod
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: npm ci
working-directory: ./client
- run: npm run build
working-directory: ./client
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: cargo install cargo-lambda
uses: taiki-e/install-action@v2
with:
tool: cargo-lambda@1
- name: Install zig for cargo-lambda
run: sudo snap install zig --classic --beta
- run: cargo lambda build --release --arm64
working-directory: ./server
- uses: hashicorp/tfc-workflows-github/actions/[email protected]
id: upload
with:
workspace: ${{ env.TF_WORKSPACE }}
# directory: ${{ env.CONFIG_DIRECTORY }}
- uses: hashicorp/tfc-workflows-github/actions/[email protected]
id: create-run
with:
workspace: ${{ env.TF_WORKSPACE }}
configuration_version: ${{ steps.upload.outputs.configuration_version_id }}
- uses: hashicorp/tfc-workflows-github/actions/[email protected]
id: apply
if: ${{ fromJSON(steps.create-run.outputs.payload).data.attributes.actions.IsConfirmable }}
with:
run: ${{ steps.create-run.outputs.run_id }}
comment: "Apply Run from GitHub Actions CI ${{ github.sha }}"