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

fix: sandbox deployment crashes and discord is not updated anymore #258

Merged
merged 3 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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