-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate to Terraform/OpenTofu remote state
Terraform state should not live in Git repos, and should instead be securely stored on a remote backend. This is that change.
- Loading branch information
1 parent
1843269
commit 20dc7a7
Showing
4 changed files
with
197 additions
and
96 deletions.
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 |
---|---|---|
@@ -1,46 +1,72 @@ | ||
name: Build and Deploy | ||
on: [push] | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-and-deploy: | ||
build: | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: opentofu/setup-opentofu@v1 | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
persist-credentials: false | ||
submodules: "true" | ||
token: ${{ secrets.ORDLIST_TOKEN }} | ||
|
||
- name: Install | ||
env: | ||
PUBLIC_URL: / | ||
run: | | ||
npm ci | ||
- id: "auth" | ||
name: "Authenticate to Google Cloud" | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
create_credentials_file: true | ||
workload_identity_provider: "projects/594849475420/locations/global/workloadIdentityPools/github-pool/providers/github-provider" | ||
|
||
- uses: opentofu/setup-opentofu@v1 | ||
|
||
- name: "Set environment variables" | ||
run: | | ||
echo "VITE_RELEASE=${GITHUB_SHA:0:8}" >> $GITHUB_ENV | ||
- name: Build | ||
- name: Install and Build 🔧 | ||
env: | ||
PUBLIC_URL: / | ||
run: | | ||
./build.sh | ||
- run: tofu init | ||
- id: plan | ||
run: tofu plan -no-color | ||
- name: Terraform | ||
run: | | ||
tofu init | ||
tofu plan -no-color | ||
tofu state rm cloudflare_zone_settings_override.ssl_settings || true | ||
tofu apply -auto-approve | ||
env: | ||
TF_VAR_cloudflare_api_token: ${{ secrets.TF_VAR_cloudflare_api_token }} | ||
TF_VAR_github_token: ${{ secrets.TF_VAR_github_token }} | ||
TF_LOG: ${{ vars.TF_LOG }} | ||
|
||
- name: Deploy 🚀 | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
- name: Upload static files as artifact | ||
id: deployment | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
branch: gh-pages # The branch the action should deploy to. | ||
folder: dist # The folder the action should deploy. | ||
clean: true # Automatically remove deleted files from the deploy branch | ||
path: dist/ | ||
|
||
- run: | | ||
tofu state rm cloudflare_zone_settings_override.ssl_settings | ||
tofu apply -auto-approve | ||
env: | ||
TF_VAR_cloudflare_api_token: ${{ secrets.TF_VAR_cloudflare_api_token }} | ||
deploy: | ||
needs: build | ||
|
||
permissions: | ||
pages: write | ||
id-token: write | ||
|
||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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,6 @@ | ||
terraform { | ||
backend "gcs" { | ||
prefix = "ordle/terraform" | ||
bucket = "terraform-remote-backend-2180c2249d350f10" | ||
} | ||
} |
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.