Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAT-16244

DevOps :: Spacelift replacement of Terraform Cloud #107

Merged
merged 63 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5d7cd83
chore(generate.yml): add environment variables for Spacelift API key …
Jan 3, 2024
ca021fc
chore(main.tf): remove unused backend configuration in terraform block
Jan 3, 2024
1693d3d
chore(main.tf): add remote backend configuration for Terraform to use…
Jan 3, 2024
d36f91d
chore(generate.yml): remove unnecessary Terraform setup step
Jan 3, 2024
e2a203b
chore(generate.yml): update environment variable names for Spacelift …
Jan 4, 2024
35755c6
chore(generate.yml): add environment variable TF_VAR_BOT_TOKEN to pro…
Jan 4, 2024
75368bf
Merge pull request #101 from liquibase/DAT-16244
jandroav Jan 4, 2024
6463faa
chore(main.tf): remove unused backend configuration in terraform file
Jan 4, 2024
5e70fd7
Merge branch 'main' into DAT-16244
jandroav Jan 4, 2024
1eba295
chore(main.tf): add remote backend configuration for Terraform to use…
Jan 4, 2024
ead9a79
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
Jan 4, 2024
7014c8c
fix(generate.yml): remove unnecessary -lock=false flag from terraform…
Jan 4, 2024
76a10c3
fix(generate.yml): add -lock=false flag to terraform apply command to…
Jan 4, 2024
1710f56
fix(generate.yml): update Terraform State Push step to disable lockin…
Jan 4, 2024
6eb96b8
fix(generate.yml): add -force flag to terraform state push command to…
Jan 4, 2024
6ffa4fe
fix(generate.yml): add cat command to print contents of errored.tfsta…
Jan 4, 2024
0e59cfa
fix(generate.yml): increment serial number and update terraform versi…
Jan 4, 2024
045e6bf
chore(main.tf): add required_version to terraform block to enforce a …
Jan 4, 2024
8f0ff5b
downgrade terraform version for spacelift
jandroav Jan 4, 2024
1afc222
Merge pull request #103 from liquibase/jandroav-patch-1
jandroav Jan 4, 2024
41ec14e
Merge branch 'main' into DAT-16244
jandroav Jan 4, 2024
cebae87
chore(generate.yml): comment out unused steps in the workflow file
Jan 4, 2024
ed90378
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
Jan 4, 2024
af4c307
chore(generate.yml): update hashicorp/setup-terraform action to versi…
Jan 4, 2024
519723f
chore(main.tf): remove unused backend configuration for remote state …
Jan 4, 2024
83d8685
chore(main.tf): add remote backend configuration for Terraform state …
Jan 4, 2024
73a7e35
chore(main.tf): remove unused backend configuration to simplify the T…
Jan 4, 2024
b5e3294
chore(main.tf): update provider owner from "liquibase" to "liquibase-…
Jan 4, 2024
f011bdf
chore(.gitignore): remove unused 'commands.json' file from being trac…
Jan 4, 2024
c217578
chore(main.tf): update commands list in locals to include all availab…
Jan 4, 2024
13d5995
chore(main.tf): refactor commands variable to use double quotes for c…
Jan 4, 2024
089744d
chore(.gitignore): add commands.json to the list of ignored files
Jan 4, 2024
a58a494
fix(generate.yml): add -lock=false flag to the terraform plan command…
Jan 4, 2024
8498233
chore(generate.yml): uncomment Terraform Apply and Terraform State Pu…
Jan 4, 2024
de5be58
chore(generate.yml): remove Terraform State Push step from the workflow
Jan 4, 2024
a42921e
chore(generate.yml): remove trailing whitespace to improve code reada…
Jan 4, 2024
eaf3972
chore(terraform): add .terraform.lock.hcl file to track provider vers…
Jan 4, 2024
c15579c
chore(.terraform.lock.hcl): add newline at the end of the file for co…
Jan 4, 2024
c2d9f64
fix(generate.yml): add `-reconfigure` flag to `terraform init` comman…
Jan 4, 2024
0ad35d4
fix(generate.yml): add -lock=false flag to the terraform state push c…
Jan 4, 2024
8b0021a
fix(generate.yml): change output file name from current_state.tfstate…
Jan 4, 2024
4a195c3
chore(generate.yml): update workflow to install spacectl instead of t…
Jan 5, 2024
c54161b
fix(generate.yml): update spacectl command to use 'preview' instead o…
Jan 5, 2024
1f1c5db
chore(generate.yml): comment out unused workflow steps to improve rea…
Jan 5, 2024
d5b80f3
fix(generate.yml): change 'spacectl stack preview' command to 'spacec…
Jan 5, 2024
9bd1493
fix(main.tf): fix file path for commands.json to be relative to the c…
Jan 5, 2024
c391921
chore(generate.yml): add ls -ltr command before running spacectl stac…
Jan 5, 2024
1c02d4f
chore(.gitignore): remove unused "commands.json" file from git tracking
Jan 5, 2024
b8ba8c7
chore(generate.yml): remove commands.json from .gitignore to allow up…
Jan 5, 2024
46b52cc
chore(generate.yml): uncomment deploy infrastructure step to enable d…
Jan 5, 2024
9c5f039
chore(generate.yml): remove commands.json from .gitignore to allow up…
Jan 5, 2024
b874569
fix(generate.yml): add condition to deploy infrastructure and generat…
Jan 5, 2024
8f92db3
fix(generate.yml): update spacectl stack deploy command to include se…
Jan 5, 2024
48d2613
DAT-16244 DevOps :: Spacelift replacement of Terraform Cloud (#104)
jandroav Jan 5, 2024
d7c047f
fix commit param to sha (#105)
jandroav Jan 5, 2024
f743fe4
chore(generate.yml): add workflow step to check for changes in comman…
Jan 5, 2024
e382842
fix conflicts
Jan 5, 2024
b4633e4
chore(generate.yml): update git command to add commands.json file for…
Jan 5, 2024
5f68799
Update commands.json
liquibot Jan 5, 2024
cec91f7
chore(.gitignore): add .terraform.lock.hcl to the list of ignored fil…
Jan 5, 2024
fe79f03
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
Jan 5, 2024
a35a9a4
chore(generate.yml): remove unnecessary step to check for changes in …
Jan 5, 2024
773a72c
chore(generate.yml): remove unnecessary commit and push commands.json…
Jan 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ jobs:
path: commands.json

create-action-repo:
env:
TF_VAR_BOT_TOKEN: ${{ secrets.GHA_GENERATOR_ADMIN_TOKEN }}
TF_TOKEN_spacelift_io: ${{ secrets.SPACELIFT_API_KEY }}

runs-on: ubuntu-latest
needs: [ create-command-list ]
steps:
- uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Install spacectl
uses: spacelift-io/setup-spacectl@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/download-artifact@v3
with:
Expand All @@ -53,25 +57,31 @@ jobs:
id: validate
run: terraform validate -no-color

- name: Terraform Plan
id: plan
run: terraform plan -no-color
continue-on-error: true
- name: Preview infrastructure
env:
TF_VAR_BOT_TOKEN: ${{ secrets.GHA_GENERATOR_ADMIN_TOKEN }}
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 local-preview --id liquibase-github-actions --disregard-gitignore=true

- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Mount commands.json
run: |
spacectl stack environment mount --id liquibase-github-actions commands.json commands.json

- name: Terraform Apply
run: terraform apply -auto-approve
- name: Deploy infrastructure
if: github.ref == 'refs/heads/main'
env:
TF_VAR_BOT_TOKEN: ${{ secrets.GHA_GENERATOR_ADMIN_TOKEN }}
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) }}
Expand All @@ -98,7 +108,7 @@ jobs:
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 ]
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ liquibase_libs
.terraform
commands.json
action
.fleet
.fleet
.terraform.lock.hcl
24 changes: 0 additions & 24 deletions .terraform.lock.hcl

This file was deleted.

22 changes: 8 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
terraform {
cloud {
organization = "liquibase"
workspaces {
name = "liquibase-github-actions"
}
}
required_providers {
github = {
source = "integrations/github"
Expand All @@ -23,12 +17,12 @@ locals {
}

resource "github_repository" "liquibase-github-actions" {
for_each = toset(local.commands)
name = replace(each.key, " ", "-")
description = "Official GitHub Action to run Liquibase ${title(replace(each.key, "-", " "))}"
visibility = "public"
has_downloads = false
has_issues = false
has_projects = false
has_wiki = false
for_each = toset(local.commands)
name = replace(each.key, " ", "-")
description = "Official GitHub Action to run Liquibase ${title(replace(each.key, "-", " "))}"
visibility = "public"
has_downloads = false
has_issues = false
has_projects = false
has_wiki = false
}
Loading