feat(examples): Update the NextJS example #263
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: | |
push: | |
branches: ["*"] | |
tags: ["v*"] | |
pull_request: | |
branches: ["*"] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Install dependencies | |
run: go get . | |
- name: Build | |
run: go build -v ./... | |
test: | |
name: "Test" | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Create a .env.test file | |
run: | | |
touch .env.test | |
echo "CS_API_KEY=\"${{ vars.CS_API_KEY }}\"" >> .env.test | |
echo "CS_DELIVERY_TOKEN=\"${{ vars.CS_DELIVERY_TOKEN }}\"" >> .env.test | |
echo "CS_MANAGEMENT_TOKEN=\"${{ vars.CS_MANAGEMENT_TOKEN }}\"" >> .env.test | |
echo "CS_BRANCH=\"${{ vars.CS_BRANCH }}\"" >> .env.test | |
echo "CS_REGION=\"${{ vars.CS_REGION }}\"" >> .env.test | |
echo "DB_CONN=\"file:db_test.sqlite3\"" >> .env.test | |
echo "DB_TYPE=\"sqlite3\"" >> .env.test | |
- name: Create a test results directory | |
run: mkdir test-results | |
- name: Run tests | |
run: | | |
go test "./..." -coverprofile="test-results/coverage.out" -covermode=count -json > test-results/test-report.out | |
- name: Delete the .env.test file after tests are completed | |
run: rm .env.test | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: test-results | |
path: test-results/ | |
sonar-scan: | |
name: "SonarQube Scan" | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
- name: SonarQube Scan | |
uses: SonarSource/sonarqube-scan-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
deploy: | |
name: "Release" | |
needs: [build, test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install "syft" | |
run: | | |
/bin/bash -c "curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin" | |
- name: "Run GoReleaser" | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: | |
startsWith(github.ref, 'refs/tags/') |