From 6905b5bfcab880a2ef40f50338eda79da0c9b4bc Mon Sep 17 00:00:00 2001 From: Frank Lyder Bredland Date: Tue, 3 Sep 2024 15:53:49 +0200 Subject: [PATCH] Github workflows (CI og Pages) --- .github/actions/install/action.yaml | 16 +++++++++++ .github/workflows/cd-github-pages.yml | 39 +++++++++++++++++++++++++++ .github/workflows/ci.yml | 35 ++++++++++++++++++++++++ capra-fagradar/package.json | 1 + 4 files changed, 91 insertions(+) create mode 100644 .github/actions/install/action.yaml create mode 100644 .github/workflows/cd-github-pages.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/actions/install/action.yaml b/.github/actions/install/action.yaml new file mode 100644 index 00000000..dad70154 --- /dev/null +++ b/.github/actions/install/action.yaml @@ -0,0 +1,16 @@ +name: 'pnpm install' +description: 'Doing installs' +runs: + using: 'composite' + steps: + - name: 'Setting up Node' + uses: actions/setup-node@v4 + with: + node-version-file: '.node-version' + + # Should pick pnpm verison based on `.packageManager` in package.json + - uses: pnpm/action-setup@v4 + + - name: Install dependencies + shell: bash + run: pnpm install diff --git a/.github/workflows/cd-github-pages.yml b/.github/workflows/cd-github-pages.yml new file mode 100644 index 00000000..2260e7a2 --- /dev/null +++ b/.github/workflows/cd-github-pages.yml @@ -0,0 +1,39 @@ +name: CD Github Pages + +on: + push: + branches: + - main + +jobs: + deploy-github-pages: + runs-on: ubuntu-latest + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: 'Checking Out Code' + uses: actions/checkout@v4 + + - name: 'Installing Dependencies' + uses: ./.github/actions/install + + - name: 'Build' + run: pnpm --filter "capra-fagradar" build + + - name: 'upload' + uses: actions/upload-pages-artifact@v3 + with: + path: ./capra-fagradar/dist + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4b07101b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: 'Tests' + runs-on: ubuntu-latest + steps: + - name: 'Checking Out Code' + uses: actions/checkout@v4 + + - name: 'Installing Dependencies' + uses: ./.github/actions/install + + - name: 'Running Unit Tests' + run: pnpm --filter "capra-fagradar" test + + build: + name: 'Builds' + runs-on: ubuntu-latest + steps: + - name: 'Checking Out Code' + uses: actions/checkout@v4 + + - name: 'Installing Dependencies' + uses: ./.github/actions/install + + - name: 'Building' + run: pnpm --filter "capra-fagradar" build diff --git a/capra-fagradar/package.json b/capra-fagradar/package.json index 4a822695..845690db 100644 --- a/capra-fagradar/package.json +++ b/capra-fagradar/package.json @@ -7,6 +7,7 @@ "dev": "vite", "build": "tsc -b && vite build", "preview": "vite preview", + "test": "echo 'no test'", "typecheck": "tsc -b" }, "dependencies": {