-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (70 loc) · 2.59 KB
/
Copy pathrelease_created.yaml
File metadata and controls
75 lines (70 loc) · 2.59 KB
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
name: Github Release Created
on:
workflow_call:
inputs:
nodejs_version:
description: "Node.js version, set by the CI/CD pipeline workflow"
required: true
type: string
pnpm_version:
description: "pnpm version, set by the CI/CD pipeline workflow"
required: true
type: string
release:
types: ["published"] # Inherits all input defaults
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
metadata:
name: "Set CI/CD metadata"
runs-on: ubuntu-latest
timeout-minutes: 1
permissions:
contents: read
outputs:
nodejs_version: ${{ steps.variables.outputs.nodejs_version }}
pnpm_version: ${{ steps.variables.outputs.pnpm_version }}
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Set CI/CD variables"
id: variables
run: |
echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
echo "pnpm_version=$(grep "^pnpm\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
deploy-main:
name: Package and Publish Terraform Modules to GitHub Releases assets
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Node install and setup
uses: ./.github/actions/node-install
with:
node-version: ${{ inputs.nodejs_version }}
pnpm-version: ${{ inputs.pnpm_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Install dependencies"
run: pnpm install --frozen-lockfile
- name: "Package and Publish Terraform modules"
run: |
ARTIFACTS_DIR="$PWD/../../artifacts"
mkdir -p "$ARTIFACTS_DIR"
cd infrastructure/terraform/modules
for module in */; do
module_name=${module%/}
if [ -f "$module_name/pre.sh" ]; then
echo "Running pre.sh for $module_name..."
(cd "$module_name" && bash pre.sh)
fi
echo "Zipping contents of $module_name..."
(cd "$module_name" && zip -r "$ARTIFACTS_DIR/terraform-${module_name}.zip" .)
echo "Publishing $module_name module..."
gh release upload ${{ github.event.release.tag_name }} "$ARTIFACTS_DIR/terraform-${module_name}.zip" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}