-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 62 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 …
ca021fc
chore(main.tf): remove unused backend configuration in terraform block
1693d3d
chore(main.tf): add remote backend configuration for Terraform to use…
d36f91d
chore(generate.yml): remove unnecessary Terraform setup step
e2a203b
chore(generate.yml): update environment variable names for Spacelift …
35755c6
chore(generate.yml): add environment variable TF_VAR_BOT_TOKEN to pro…
75368bf
Merge pull request #101 from liquibase/DAT-16244
jandroav 6463faa
chore(main.tf): remove unused backend configuration in terraform file
5e70fd7
Merge branch 'main' into DAT-16244
jandroav 1eba295
chore(main.tf): add remote backend configuration for Terraform to use…
ead9a79
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
7014c8c
fix(generate.yml): remove unnecessary -lock=false flag from terraform…
76a10c3
fix(generate.yml): add -lock=false flag to terraform apply command to…
1710f56
fix(generate.yml): update Terraform State Push step to disable lockin…
6eb96b8
fix(generate.yml): add -force flag to terraform state push command to…
6ffa4fe
fix(generate.yml): add cat command to print contents of errored.tfsta…
0e59cfa
fix(generate.yml): increment serial number and update terraform versi…
045e6bf
chore(main.tf): add required_version to terraform block to enforce a …
8f0ff5b
downgrade terraform version for spacelift
jandroav 1afc222
Merge pull request #103 from liquibase/jandroav-patch-1
jandroav 41ec14e
Merge branch 'main' into DAT-16244
jandroav cebae87
chore(generate.yml): comment out unused steps in the workflow file
ed90378
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
af4c307
chore(generate.yml): update hashicorp/setup-terraform action to versi…
519723f
chore(main.tf): remove unused backend configuration for remote state …
83d8685
chore(main.tf): add remote backend configuration for Terraform state …
73a7e35
chore(main.tf): remove unused backend configuration to simplify the T…
b5e3294
chore(main.tf): update provider owner from "liquibase" to "liquibase-…
f011bdf
chore(.gitignore): remove unused 'commands.json' file from being trac…
c217578
chore(main.tf): update commands list in locals to include all availab…
13d5995
chore(main.tf): refactor commands variable to use double quotes for c…
089744d
chore(.gitignore): add commands.json to the list of ignored files
a58a494
fix(generate.yml): add -lock=false flag to the terraform plan command…
8498233
chore(generate.yml): uncomment Terraform Apply and Terraform State Pu…
de5be58
chore(generate.yml): remove Terraform State Push step from the workflow
a42921e
chore(generate.yml): remove trailing whitespace to improve code reada…
eaf3972
chore(terraform): add .terraform.lock.hcl file to track provider vers…
c15579c
chore(.terraform.lock.hcl): add newline at the end of the file for co…
c2d9f64
fix(generate.yml): add `-reconfigure` flag to `terraform init` comman…
0ad35d4
fix(generate.yml): add -lock=false flag to the terraform state push c…
8b0021a
fix(generate.yml): change output file name from current_state.tfstate…
4a195c3
chore(generate.yml): update workflow to install spacectl instead of t…
c54161b
fix(generate.yml): update spacectl command to use 'preview' instead o…
1f1c5db
chore(generate.yml): comment out unused workflow steps to improve rea…
d5b80f3
fix(generate.yml): change 'spacectl stack preview' command to 'spacec…
9bd1493
fix(main.tf): fix file path for commands.json to be relative to the c…
c391921
chore(generate.yml): add ls -ltr command before running spacectl stac…
1c02d4f
chore(.gitignore): remove unused "commands.json" file from git tracking
b8ba8c7
chore(generate.yml): remove commands.json from .gitignore to allow up…
46b52cc
chore(generate.yml): uncomment deploy infrastructure step to enable d…
9c5f039
chore(generate.yml): remove commands.json from .gitignore to allow up…
b874569
fix(generate.yml): add condition to deploy infrastructure and generat…
8f92db3
fix(generate.yml): update spacectl stack deploy command to include se…
48d2613
DAT-16244 DevOps :: Spacelift replacement of Terraform Cloud (#104)
jandroav d7c047f
fix commit param to sha (#105)
jandroav f743fe4
chore(generate.yml): add workflow step to check for changes in comman…
e382842
fix conflicts
b4633e4
chore(generate.yml): update git command to add commands.json file for…
5f68799
Update commands.json
liquibot cec91f7
chore(.gitignore): add .terraform.lock.hcl to the list of ignored fil…
fe79f03
Merge branch 'DAT-16244' of https://github.com/liquibase/github-actio…
a35a9a4
chore(generate.yml): remove unnecessary step to check for changes in …
773a72c
chore(generate.yml): remove unnecessary commit and push commands.json…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -53,25 +57,36 @@ 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: Commit and push commands.json changes | ||
continue-on-error: true | ||
run: | | ||
git config --global user.name "liquibot" | ||
git config --global user.email "[email protected]" | ||
git add --force commands.json | ||
git commit -m "Update commands.json" -a | ||
git push | ||
|
||
- 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) }} | ||
|
@@ -98,7 +113,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 ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ liquibase_libs | |
.terraform | ||
commands.json | ||
action | ||
.fleet | ||
.fleet | ||
.terraform.lock.hcl |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["calculate-checksum","changelog-sync","changelog-sync-sql","changelog-sync-to-tag","changelog-sync-to-tag-sql","checks bulk-set","checks copy","checks create","checks customize","checks delete","checks disable","checks enable","checks reset","checks run","checks show","clear-checksums","connect","db-doc","diff","diff-changelog","drop-all","execute-sql","flow","flow validate","future-rollback-count-sql","future-rollback-from-tag-sql","future-rollback-sql","generate-changelog","history","init copy","init project","init start-h2","list-locks","mark-next-changeset-ran","mark-next-changeset-ran-sql","release-locks","rollback","rollback-count","rollback-count-sql","rollback-one-changeset","rollback-one-changeset-sql","rollback-one-update","rollback-one-update-sql","rollback-sql","rollback-to-date","rollback-to-date-sql","set-contexts","set-labels","snapshot","snapshot-reference","status","tag","tag-exists","unexpected-changesets","update","update-count","update-count-sql","update-one-changeset","update-one-changeset-sql","update-sql","update-testing-rollback","update-to-tag","update-to-tag-sql","validate"] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file shouldn't be in version control IMO. It's only used between steps during automation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mcred I agree with you but Spacelift deploys the stuff which is only in the repository. Spacelift can only "user" local files for previewing. Spacelift can perform some kind of terraform planning using the current working directory, but it will only deploy pushed stuff. We could remove the file from the repo after executing the
spacectl stack deploy --id liquibase-github-actions --auto-confirm
command.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"will only deploy pushed stuff" seems problematic. Would this mean that during automation we would need to update the file, push it to the repo, and then let spacelift check it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are already updating the file with
github-action-generator/.github/workflows/generate.yml
Line 18 in f6c751d
The only change is about pushing the file if there are changes on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mcred I think we can do the following to not push the file.
We can run the following
spacectl
command before deploying stuff:That command will mount the
commands.json
file in the Spacelift backend ready to be used by Terraform:I have updated the PR with the change. Please tell me if this works better.