feat: github actions rework #13
Workflow file for this run
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
name: CI | |
on: | |
pull_request: | |
branches: ["master"] | |
push: | |
branches: ["master"] | |
workflow_call: | |
jobs: | |
prettier: | |
name: Prettier | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Install Prettier | |
run: npm install --global prettier | |
- name: Run Prettier | |
run: prettier --check --no-error-on-unmatched-pattern "**/*.{json,md,yml,yaml}" | |
prettier_action: | |
name: Prettier 2 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Run Prettier | |
uses: creyD/prettier_action@v4.3 | |
with: | |
prettier_options: --check --no-error-on-unmatched-pattern "**/*.{json,md,yml,yaml}" | |
check: | |
name: Mix Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: "1.15.7" | |
otp-version: "26" | |
- name: Restore dependencies cache | |
uses: actions/cache@v3 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Run formatter | |
run: mix format --check-formatted | |
image_build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
hpopp/tarot-cup | |
tags: | | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
tags: ${{ steps.meta.outputs.tags }} | |
outputs: type=docker,dest=/tmp/image.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: image | |
path: /tmp/image.tar | |
trivy: | |
name: Trivy Scan | |
runs-on: ubuntu-latest | |
needs: image_build | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: image | |
- name: Run Trivy vulnerability scanner in tarball mode | |
uses: aquasecurity/trivy-action@master | |
with: | |
input: image.tar | |
severity: "CRITICAL" |