-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (103 loc) · 3.74 KB
/
generate.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Generate Action
on:
workflow_dispatch:
env:
LIQUIBASE_VERSION: 4.31.1
jobs:
create-command-list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: create list
run: make create-list VERSION=$LIQUIBASE_VERSION
- id: set-matrix
run: echo "matrix=$(cat commands.json)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: commands-$LIQUIBASE_VERSION
path: commands.json
create-action-repo:
env:
TF_VAR_BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
TF_TOKEN_spacelift_io: ${{ secrets.SPACELIFT_API_KEY }}
SPACELIFT_API_KEY_ENDPOINT: ${{ secrets.SPACELIFT_API_KEY_ENDPOINT }}
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
runs-on: ubuntu-latest
needs: [ create-command-list ]
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.5.7"
terraform_wrapper: false
- name: Install spacectl
uses: spacelift-io/setup-spacectl@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: commands-$LIQUIBASE_VERSION
path: ./
- name: Terraform Format
id: fmt
run: terraform fmt
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Preview infrastructure
run: spacectl stack local-preview --id liquibase-github-actions --disregard-gitignore=true
- name: Mount commands.json
run: |
spacectl stack environment mount --id liquibase-github-actions source/commands.json commands.json
- name: Deploy infrastructure
if: github.ref == 'refs/heads/main'
env:
SPACELIFT_API_KEY_ENDPOINT: ${{ secrets.SPACELIFT_API_KEY_ENDPOINT }}
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
run: |
spacectl stack set-current-commit --id liquibase-github-actions --sha ${{ github.sha }}
spacectl stack deploy --id liquibase-github-actions --auto-confirm
generate-action:
runs-on: ubuntu-latest
needs: [ create-command-list, create-action-repo ]
if: github.ref == 'refs/heads/main'
strategy:
matrix:
commands: ${{ fromJSON(needs.create-command-list.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- run: echo ${{ matrix.commands }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.BOT_TOKEN }}
- run: make generate VERSION=$LIQUIBASE_VERSION COMMAND="${{ matrix.commands }}"
- name: Configure git user
run: |
git config --global init.defaultBranch main
git config --global user.name "liquibot"
git config --global user.email "[email protected]"
- name: Push Action to Repo
run: ./scripts/push-to-repository.sh "${{ matrix.commands }}" $LIQUIBASE_VERSION
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
output-action:
runs-on: ubuntu-latest
needs: [ generate-action ]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: commands-$LIQUIBASE_VERSION
path: ./
- name: Output Action Edit Link
run: ./scripts/output-release-edit.sh "v$LIQUIBASE_VERSION"