💚 Remove sign of images #73
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: Main | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
jobs: | |
main: | |
name: Run main Job | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
packages: write | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: 'Dependency Review' | |
if: github.event_name == 'pull_request' | |
uses: actions/dependency-review-action@v3 | |
- name: 'Dependency Review' | |
if: github.event_name != 'pull_request' | |
uses: actions/dependency-review-action@v3 | |
with: | |
base-ref: ${{ github.event.before }} | |
head-ref: ${{ github.event.after }} | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/cosign-installer@v3.1.2 | |
with: | |
cosign-release: 'v2.1.1' | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v2.10.0 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: 'go, javascript' | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
package_json_file: ui/package.json | |
version: 9 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.x | |
cache-dependency-path: ui/pnpm-lock.yaml | |
cache: 'pnpm' | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
# We don't want to build the entire frondend, so we are using standalone npm ci | |
- name: Install frontend packages (w/o go generate) | |
working-directory: ./ui | |
run: | | |
pnpm i --frozen-lockfile | |
- name: Install ESLint and Prettier | |
working-directory: ./ui | |
run: | | |
pnpm -w install eslint@8 | |
pnpm -w install prettier | |
pnpm -w install @microsoft/eslint-formatter-sarif | |
- name: Run ESLint | |
working-directory: ./ui | |
run: npx --yes eslint . --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif | |
continue-on-error: true | |
- name: Upload analysis results to GitHub | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: ui/eslint-results.sarif | |
wait-for-processing: true | |
- name: Run Prettier | |
working-directory: ui | |
run: npx --yes prettier src/ | |
- name: Download go dependencies | |
run: go mod download | |
- name: Build Frontend (Go generate) | |
run: go generate ./... | |
- name: Go build | |
run: go build -x -o ./url-shortener . | |
- name: Perform CodeQL Analysis (Go) | |
uses: github/codeql-action/analyze@v2 | |
with: | |
category: '/language:go' | |
- name: Perform CodeQL Analysis (JavaScript) | |
uses: github/codeql-action/analyze@v2 | |
with: | |
category: '/language:javascript' | |
- name: Run Codacy Analysis CLI (Metrics) | |
uses: codacy/codacy-analysis-cli-action@v4.3.0 | |
id: codacy_metrics | |
with: | |
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
verbose: true | |
output: metrics_results.sarif | |
format: sarif | |
gh-code-scanning-compat: true | |
max-allowed-issues: 2147483647 | |
tool: metrics | |
- name: Upload Codacy SARIF results file (Metrics) | |
uses: github/codeql-action/upload-sarif@v2 | |
continue-on-error: true # Ignore 422 errors (when there is no result) | |
with: | |
sarif_file: metrics_results.sarif | |
- name: Run Codacy Analysis CLI (Issues) | |
uses: codacy/codacy-analysis-cli-action@v4.3.0 | |
with: | |
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
verbose: true | |
output: issues_results.sarif | |
format: sarif | |
gh-code-scanning-compat: true | |
max-allowed-issues: 2147483647 | |
tool: issues | |
- name: Upload Codacy SARIF results file (Issues) | |
continue-on-error: true # Ignore 422 errors (when there is no result) | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: issues_results.sarif | |
- name: Run Codacy Analysis CLI (Duplication) | |
uses: codacy/codacy-analysis-cli-action@v4.3.0 | |
with: | |
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
verbose: true | |
output: duplication_results.sarif | |
format: sarif | |
gh-code-scanning-compat: true | |
max-allowed-issues: 2147483647 | |
tool: duplication | |
- name: Upload Codacy SARIF results file (Duplication) | |
continue-on-error: true # Ignore 422 errors (when there is no result) | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: duplication_results.sarif | |
- name: Log into registry ghcr.io | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2.2.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4.6.0 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v4.2.1 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |