Skip to content

Added loki & custom cert-manager #55

Added loki & custom cert-manager

Added loki & custom cert-manager #55

Workflow file for this run

name: "Pipeline"
on:
push:
branches:
- main
pull_request:
env:
TF_VAR_access_key_id: ${{ secrets.SCW_ACCESS_KEY_ID }}
TF_VAR_secret_key: ${{ secrets.SCW_ACCESS_KEY }}
TF_VAR_project_id: ${{ secrets.SCW_PROJECT_ID }}
TF_VAR_backend_tmdb_api_key: ${{ secrets.TMDB_API_KEY }}
TF_VAR_backend_admin_password: ${{ secrets.ADMIN_PASSWORD }}
TF_VAR_backend_google_auth_client_id: ${{ secrets.GOOGLE_AUTH_CLIENT_ID }}
TF_VAR_backend_google_auth_client_secret: ${{ secrets.GOOGLE_AUTH_CLIENT_SECRET }}
TF_VAR_backend_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_mongo_root_password: ${{ secrets.MONGO_ROOT_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.SCW_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
jobs:
frontend:
name: "Frontend"
runs-on: ubuntu-latest
env:
WORKING_DIRECTORY: packages/frontend
outputs:
image-tag: ${{ steps.extract-tag.outputs.image-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: steps.cache-npm.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
name: List the state of node modules
continue-on-error: true
run: npm list
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Install dependencies
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: npm install
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Log in to Scaleway Container Registry
uses: docker/login-action@v2
with:
registry: rg.fr-par.scw.cloud/app-namespace
username: ${{ secrets.SCW_ACCESS_KEY_ID }}
password: ${{ secrets.SCW_ACCESS_KEY }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: rg.fr-par.scw.cloud/app-namespace/frontend
tags: |
latest
type=sha
- name: Build and push
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: docker/build-push-action@v4
with:
context: ${{ env.WORKING_DIRECTORY }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract second tag (sha)
id: extract-tag
run: |
TAGS=(${{ steps.meta.outputs.tags }})
echo "image-tag=${TAGS[1]}" >> "$GITHUB_OUTPUT"
backend:
name: "Backend"
runs-on: ubuntu-latest
env:
WORKING_DIRECTORY: packages/backend
outputs:
image-tag: ${{ steps.extract-tag.outputs.image-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: steps.cache-npm.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
name: List the state of node modules
continue-on-error: true
run: npm list
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Install dependencies
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: npm install
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Log in to Scaleway Container Registry
uses: docker/login-action@v2
with:
registry: rg.fr-par.scw.cloud/app-namespace
username: ${{ secrets.SCW_ACCESS_KEY_ID }}
password: ${{ secrets.SCW_ACCESS_KEY }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: rg.fr-par.scw.cloud/app-namespace/backend
tags: |
latest
type=sha
- name: Build and push
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: docker/build-push-action@v4
with:
context: ${{ env.WORKING_DIRECTORY }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract second tag (sha)
id: extract-tag
run: |
TAGS=(${{ steps.meta.outputs.tags }})
echo "image-tag=${TAGS[1]}" >> "$GITHUB_OUTPUT"
terraform:
name: "Terraform"
runs-on: ubuntu-latest
needs:
- backend
- frontend
permissions:
pull-requests: write
env:
WORKING_DIRECTORY: packages/infrastructure/project
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Format
id: fmt
run: terraform fmt -check
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Terraform Init
id: init
run: terraform init
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Terraform Validate
id: validate
run: terraform validate -no-color
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Write image tags in environment
run: |
echo "TF_VAR_frontend_image=${{ needs.frontend.outputs.image-tag }}" >> $GITHUB_ENV
echo "TF_VAR_backend_image=${{ needs.backend.outputs.image-tag }}" >> $GITHUB_ENV
- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: |
terraform plan -no-color -input=false
continue-on-error: true
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Update Pull Request
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: ${{ steps.plan.outputs.stdout }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`terraform\n
${process.env.PLAN}
\`\`\`
</details>
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
terraform apply -auto-approve -input=false
working-directory: ${{ env.WORKING_DIRECTORY }}