Skip to content

ci: update pr flow #578

ci: update pr flow

ci: update pr flow #578

Workflow file for this run

name: "pull request"
on:
pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "catalog.yaml"
env:
IMAGE_PATH: ${{ github.repository_owner }}/gratibot
permissions:
id-token: write
pull-requests: write
contents: read
packages: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Setup Node
uses: actions/setup-node@master
with:
node-version: '18'
- name: Checkout Code
uses: actions/checkout@v4
- name: Run Linter
run: |
npm ci
npm run lint
test:
runs-on: ubuntu-latest
steps:
- name: Setup Node
uses: actions/setup-node@master
with:
node-version: '18'
- name: Checkout Code
uses: actions/checkout@v4
- name: Test & publish
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.code_climate_reporter_id }}
with:
coverageCommand: npm run test:ci
coverageLocations: |
${{github.workspace}}/*.lcov:lcov
setup:
name: Pipeline Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate tag
id: tag
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
outputs:
docker-tag: ${{ steps.tag.outputs.sha_short }}
build:
name: Docker
needs: setup
uses: liatrio/github-workflows/.github/workflows/docker-build.yaml@main
with:
repository: ghcr.io/liatrio
image-name: gratibot
tag: ${{ needs.setup.outputs.docker-tag }}
security:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: ghcr.io/liatrio:${{ needs.setup.outputs.docker-tag }}
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
pathsIgnore: [ "**/middleware" ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
fmt:
name: "Terraform fmt check"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform fmt check
run: terraform fmt -check -recursive
validate:
name: "Terraform validate check"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terragrunt
run: |
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.45.11/terragrunt_linux_amd64
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
- name: Terraform validate check
run: |
terragrunt init -backend=false
terragrunt validate --terragrunt-no-auto-init
working-directory: infra/terragrunt/nonprod/gratibot/
env:
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
plan:
name: "Terraform Nonprod plan"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terragrunt
run: |
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.45.11/terragrunt_linux_amd64
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
- name: Plan Gratibot staging deployment
id: plan_gratibot_staging_deployment
working-directory: infra/terragrunt/nonprod/gratibot/
run: |
terragrunt plan -out plan.out
terragrunt show -no-color -json plan.out > plan.json
continue-on-error: true
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_NONPROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
- uses: liatrio/[email protected]
with:
json-file: infra/terragrunt/nonprod/gratibot/plan.json
expand-comment: 'true'
- name: Status
if: contains(steps.*.outcome, 'failure')
run: exit 1