diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..82801ff --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,68 @@ +name: ci + +on: + push: + branches: ["*"] + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + uses: ./.forgejo/workflows/lint.yml + test: + runs-on: ubuntu-latest + uses: ./.forgejo/workflows/test.yml + deploy: + runs-on: ubuntu-latest + needs: [lint, test] + if: forgejo.ref == 'refs/heads/main' + steps: + - name: checkout code + uses: actions/checkout@v6.0.1 + - name: cache node_modules + uses: actions/cache@v4.3.0 + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + node-modules-${{ runner.os }}- + - name: install pnpm + uses: pnpm/action-setup@v4.2.0 + with: + version: 10.24.0 + run_install: true + - name: build site + run: pnpm build + - name: import gpg key + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + run: | + echo "$GPG_PRIVATE_KEY" | gpg --batch --import || true + echo "default-cache-ttl 3600" >> ~/.gnupg/gpg-agent.conf + echo RELOADAGENT | gpg-connect-agent + - name: setup git identity + run: | + git config --global user.name "forgejo-actions-bot" + git config --global user.email "actions@forgejo.local" + + KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5;exit}') + git config --global user.signingkey "$KEYID" + git config --global commit.gpgsign true + - name: deploy to gh-pages + env: + FORGEJO_TOKEN: ${{ forgejo.token }} + FORGEJO_REPOSITORY: ${{ forgejo.repository }} + run: | + git fetch --all + git checkout --orphan gh-pages + + cp -r dist/* . + rm -rf dist .astro + touch .nojekyll + echo "cpatino.com" > CNAME + + git rm -rf . + git add . ':!./.pnpm-store' ':!./node_modules' + + git commit -S -m "chore: deploy to github pages" + git push --force "https://${FORGEJO_TOKEN}@git.cpatino.com/${FORGEJO_REPOSITORY}.git" HEAD:gh-pages diff --git a/.forgejo/workflows/lint.yml b/.forgejo/workflows/lint.yml new file mode 100644 index 0000000..fce8bfc --- /dev/null +++ b/.forgejo/workflows/lint.yml @@ -0,0 +1,73 @@ +on: + workflow_call: + workflow_dispatch: + +jobs: + treefmt: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v6.0.1 + - name: install nix + uses: https://github.com/cachix/install-nix-action@v31.8.4 + - name: restore and save nix store + uses: https://github.com/nix-community/cache-nix-action@v6.1.3 + with: + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + restore-prefixes-first-match: nix-${{ runner.os }}- + gc-max-store-size-linux: 1G + purge: true + purge-prefixes: nix-${{ runner.os }}- + purge-created: 0 + purge-last-accessed: 0 + purge-primary-key: never + - name: set up nix-community cachix + uses: https://github.com/cachix/cachix-action@v16 + with: + name: nix-community + - name: setup node + uses: actions/setup-node@v6.1.0 + with: + node-version: 22 + cache: "pnpm" + - name: install pnpm + uses: https://github.com/pnpm/action-setup@v4.2.0 + with: + version: 10.24.0 + run_install: true + - name: run treefmt + run: nix fmt -- --ci --excludes ".pnpm-store/*" + eslint: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v6.0.1 + - name: setup node@6.1.0 + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + - name: install pnpm + uses: https://github.com/pnpm/action-setup@v4.2.0 + with: + version: 10.24.0 + run_install: true + - name: run eslint + run: pnpm run lint + tsc: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v6.0.1 + - name: setup node@6.1.0 + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + - name: install pnpm + uses: https://github.com/pnpm/action-setup@v4.2.0 + with: + version: 10.24.0 + run_install: true + - name: run tsc typechecking + run: pnpm run typecheck diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml new file mode 100644 index 0000000..700add0 --- /dev/null +++ b/.forgejo/workflows/test.yml @@ -0,0 +1,24 @@ +on: + workflow_call: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v6.0.1 + - name: cache node modules + uses: actions/cache@v4.3.0 + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + node-modules-${{ runner.os }}- + - name: install pnpm + uses: https://github.com/pnpm/action-setup@v4.2.0 + with: + version: 10.15.1 + run_install: true + - name: run tests + run: pnpm test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 6f8b3ff..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: ci - -on: - push: - branches: ["*"] - tags: ["v*.*.*"] - pull_request: - types: [opened, reopened, synchronize] - branches: ["*"] - workflow_dispatch: - -permissions: - contents: write - pages: write - id-token: write - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: checkout code - uses: actions/checkout@v4 - - name: setup environment - uses: c4patino/actions/.github/actions/setup-js@main - - name: install dependencies - run: pnpm install - - name: run tests - run: pnpm test - format: - uses: c4patino/actions/.github/workflows/format.yml@main - with: - language: js - command: pnpm format - lint: - runs-on: ubuntu-latest - steps: - - name: checkout code - uses: actions/checkout@v4 - - name: setup environment - uses: c4patino/actions/.github/actions/setup-js@main - - name: install dependencies - run: pnpm install - - name: run eslint - run: pnpm lint - increment: - needs: [test, format, lint] - if: github.event_name == 'push' && github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.ref == 'refs/heads/main') - uses: c4patino/actions/.github/workflows/increment.yml@main - with: - language: js - build: - runs-on: ubuntu-latest - needs: increment - steps: - - name: checkout code - uses: actions/checkout@v4 - - name: setup environment - uses: c4patino/actions/.github/actions/setup-js@main - - name: install dependencies - run: pnpm install - - name: build package - run: pnpm build - - name: upload page artifacts - uses: actions/upload-pages-artifact@v3 - with: - path: "./dist" - deploy: - runs-on: ubuntu-latest - needs: build - steps: - - name: deploy to github pages - uses: actions/deploy-pages@v4