Skip to content

Commit

Permalink
fix: sandbox deployment crashes and discord is not updated anymore (#258
Browse files Browse the repository at this point in the history
)

**Describe the pull request**

The sandbox stacks don't have the s3 backend configured and discord is
not updated on release. This PR will fixes this issues

**Checklist**

- [x] I have linked the relative issue to this pull request
- [x] I have made the modifications or added tests related to my PR
- [x] I have added/updated the documentation for my RP
- [x] I put my PR in Ready for Review only when all the checklist is
checked

**Breaking changes ?**
no
  • Loading branch information
42atomys authored Nov 20, 2022
1 parent 021531b commit 23c2172
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2,142 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,34 @@ jobs:
id: init
run: terraform init -input=false

# On push to main, build or change infrastructure according
# to Terraform configuration files
# On push to main, build or change infrastructure according
# to Terraform configuration files
- name: Terraform Apply
id: apply
env:
TF_WORKSPACE: ${{ secrets.TF_WORKSPACE }}
# TF VARS
TF_VAR_namespace: ${{ inputs.kubeNamespace }}
TF_ENV_appsVersion: '{"s42"="${{ inputs.imageTag }}"}'
TF_VAR_appsVersion: '{"s42"="${{ inputs.imageTag }}"}'
TF_VAR_baseUrl: ${{ steps.envurl.outputs.url }}
TF_VAR_webhooksEnabled: ${{ inputs.kubeNamespace == 'production' }}
TF_VAR_crawlerEnabled: ${{ inputs.kubeNamespace == 'production' }}
TF_VAR_hasProvidedJWTKSCertificates: "false"
TF_VAR_hasPersistentStorage: ${{ contains(fromJson('["production", "staging"]'), inputs.kubeNamespace) }}
run: terraform apply -auto-approve -input=false

# Update discord channel version information after all jobs are done
# under production environment.
update_discord_channel:
name: "update discord channel"
runs-on: ubuntu-latest
needs: [terraform]
if: ${{ inputs.kubeNamespace == 'production' }}
steps:
- name: Update Discord channel
run: |
curl --request PATCH \
--url https://discord.com/api/v9/channels/954496570362044466 \
--header 'Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"name": "🔖 ${{ github.event.release.tag_name }}+beta"}'
4 changes: 2 additions & 2 deletions .github/workflows/discord-push-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
{
"style": 5,
"label": "Show Full Release",
"url": "https://api.github.com/repos/42Atomys/stud42/releases/72738031",
"url": "https://github.com/42Atomys/stud42/releases/tag/${{ github.event.release.tag_name }}",
"disabled": false,
"type": 2
}
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
{
"style": 5,
"label": "Show Full Release",
"url": "${{ github.event.release.url }}",
"url": "https://github.com/42Atomys/stud42/releases/tag/${{ github.event.release.tag_name }}",
"disabled": false,
"type": 2
}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["pre-cluster", "cluster", "apps"]
stack: ["pre-cluster", "cluster", "apps", "sandbox"]
defaults:
run:
working-directory: "deploy/stacks/${{ matrix.stack }}"
Expand All @@ -17,6 +17,9 @@ jobs:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Format
env:
# Sandbox is not deployed to the production workspace.
TF_WORKSPACE: ${{ matrix.stack == 'sandbox' && 'sandbox' || 'production' }}
run: terraform fmt -check=true -recursive

backend:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ jobs:
terraform:
runs-on: ubuntu-latest
env:
TF_WORKSPACE: production # Compare the changes when plan with production
# Sandbox is not deployed to the production workspace.
# Compare the changes when plan with production
TF_WORKSPACE: ${{ matrix.stack == 'sandbox' && 'sandbox' || 'production' }}
AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }}
# TF VARS (bind to production to display changes between branch and production)
TF_VAR_namespace: production
# Compare the changes when plan with production
TF_VAR_namespace: ${{ matrix.stack == 'sandbox' && 'sandbox' || 'production' }}
TF_ENV_appsVersion: '{"s42": "${{ inputs.imageTag }}"}'
TF_VAR_baseUrl: "s42.app"
TF_VAR_webhooksEnabled: "true"
Expand All @@ -26,7 +29,7 @@ jobs:

strategy:
matrix:
stack: ["pre-cluster", "cluster", "apps"]
stack: ["pre-cluster", "cluster", "apps", "sandbox"]
defaults:
run:
working-directory: "deploy/stacks/${{ matrix.stack }}"
Expand Down
10 changes: 10 additions & 0 deletions deploy/stacks/sandbox/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
terraform {
backend "s3" {
bucket = "s42-terraform-state"
key = "sandbox.tfstate"
endpoint = "https://s3.gra.io.cloud.ovh.net/"
region = "gra"
skip_region_validation = true
skip_credentials_validation = true
}


required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
Loading

0 comments on commit 23c2172

Please sign in to comment.