From e5c37d1c8baf6e56069f47a30b592684364667a4 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Fri, 14 Jun 2024 22:53:40 +0200 Subject: [PATCH] ci: try to mostly adapt workflows Signed-off-by: Christoph Heiss --- {.github => .forgejo}/dependabot.yml | 0 {.github => .forgejo}/failing-import-issue.md | 0 .../workflows/build-flake-info.yml | 12 ++-- .../workflows/check-flake-files.yml | 13 ++--- .forgejo/workflows/frontend.yml | 30 ++++++++++ .../workflows/import-to-elasticsearch.yml | 58 ++++++------------- .../workflows/update-flake-lock.yml | 16 ++--- .github/actions/common-setup/action.yml | 23 -------- .github/workflows/frontend.yml | 51 ---------------- 9 files changed, 64 insertions(+), 139 deletions(-) rename {.github => .forgejo}/dependabot.yml (100%) rename {.github => .forgejo}/failing-import-issue.md (100%) rename {.github => .forgejo}/workflows/build-flake-info.yml (63%) rename {.github => .forgejo}/workflows/check-flake-files.yml (83%) create mode 100644 .forgejo/workflows/frontend.yml rename {.github => .forgejo}/workflows/import-to-elasticsearch.yml (65%) rename {.github => .forgejo}/workflows/update-flake-lock.yml (56%) delete mode 100644 .github/actions/common-setup/action.yml delete mode 100644 .github/workflows/frontend.yml diff --git a/.github/dependabot.yml b/.forgejo/dependabot.yml similarity index 100% rename from .github/dependabot.yml rename to .forgejo/dependabot.yml diff --git a/.github/failing-import-issue.md b/.forgejo/failing-import-issue.md similarity index 100% rename from .github/failing-import-issue.md rename to .forgejo/failing-import-issue.md diff --git a/.github/workflows/build-flake-info.yml b/.forgejo/workflows/build-flake-info.yml similarity index 63% rename from .github/workflows/build-flake-info.yml rename to .forgejo/workflows/build-flake-info.yml index 394d97e..6c6057f 100644 --- a/.github/workflows/build-flake-info.yml +++ b/.forgejo/workflows/build-flake-info.yml @@ -12,18 +12,14 @@ on: jobs: build-flake-info: - runs-on: ubuntu-latest + runs-on: nixos-unstable steps: - name: Checking out the repository uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} - - + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf - name: Building flake-info run: | diff --git a/.github/workflows/check-flake-files.yml b/.forgejo/workflows/check-flake-files.yml similarity index 83% rename from .github/workflows/check-flake-files.yml rename to .forgejo/workflows/check-flake-files.yml index 08803b1..cf1e7b8 100644 --- a/.github/workflows/check-flake-files.yml +++ b/.forgejo/workflows/check-flake-files.yml @@ -8,24 +8,19 @@ on: jobs: automatic-custom-flakes-check: - runs-on: ubuntu-latest - + runs-on: nixos-unstable strategy: fail-fast: true - env: RUST_LOG: debug steps: - - name: Checking out the repository uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf - name: Try importing all custom flakes run: | diff --git a/.forgejo/workflows/frontend.yml b/.forgejo/workflows/frontend.yml new file mode 100644 index 0000000..68be985 --- /dev/null +++ b/.forgejo/workflows/frontend.yml @@ -0,0 +1,30 @@ +name: "Frontend: Build & Deploy to Netlify" +on: + workflow_dispatch: + pull_request: + paths: + - "flake.nix" + - "flake.lock" + - "frontend/**" + - "VERSION" + + push: + branches: + - main + +jobs: + build-and-deploy: + runs-on: nixos-unstable + steps: + - name: Checking out the repository + uses: actions/checkout@v4 + + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf + + - name: Building search.nixos.org + run: | + nix -vL build .#frontend + mkdir ./dist + cp -RL ./result/* ./dist/ diff --git a/.github/workflows/import-to-elasticsearch.yml b/.forgejo/workflows/import-to-elasticsearch.yml similarity index 65% rename from .github/workflows/import-to-elasticsearch.yml rename to .forgejo/workflows/import-to-elasticsearch.yml index ed67b70..da6b636 100644 --- a/.github/workflows/import-to-elasticsearch.yml +++ b/.forgejo/workflows/import-to-elasticsearch.yml @@ -10,10 +10,8 @@ permissions: issues: write jobs: - nixos-channels: - runs-on: ubuntu-latest - + runs-on: nixos-unstable outputs: matrix: ${{ steps.nixos-channels.outputs.matrix }} @@ -21,11 +19,9 @@ jobs: - name: Checking out the repository uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf - name: NixOS Channels id: nixos-channels @@ -37,12 +33,10 @@ jobs: import-nixpkgs: needs: nixos-channels - runs-on: ubuntu-latest - + runs-on: nixos-unstable strategy: fail-fast: false matrix: ${{ fromJSON(needs.nixos-channels.outputs.matrix) }} - env: RUST_LOG: debug FI_ES_EXISTS_STRATEGY: abort @@ -52,70 +46,52 @@ jobs: - name: Checking out the repository uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf - name: Import ${{ matrix.channel }} channel env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(< VERSION) nixpkgs ${{ matrix.channel }} - if: github.repository_owner == 'NixOS' + if: false - name: Warmup ${{ matrix.channel }} channel run: | for (( i = 0; i < 3; i++ )) do curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(< VERSION)-nixos-${{ matrix.channel }}/_search | jq -c '.took // .' done - if: github.repository_owner == 'NixOS' - - - name: Create issue if failed - if: failure() - uses: JasonEtco/create-an-issue@v2 - with: - filename: .github/failing-import-issue.md - search_existing: open - update_existing: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CHANNEL: ${{ matrix.channel }} + if: false import-flakes: - runs-on: ubuntu-latest - + runs-on: nixos-unstable strategy: fail-fast: false matrix: group: - - "manual" - + - manual env: RUST_LOG: debug FI_ES_EXISTS_STRATEGY: recreate FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL2 }} steps: - - name: Checking out the repository uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf - name: Import ${{ matrix.group }} group run: | nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(< ./VERSION) group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }} - if: github.repository_owner == 'NixOS' + if: false - name: Warmup ${{ matrix.group }} group run: | for (( i = 0; i < 3; i++ )) do curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(< VERSION)-group-${{ matrix.group }}/_search | jq -c '.took // .' done - if: github.repository_owner == 'NixOS' + if: false diff --git a/.github/workflows/update-flake-lock.yml b/.forgejo/workflows/update-flake-lock.yml similarity index 56% rename from .github/workflows/update-flake-lock.yml rename to .forgejo/workflows/update-flake-lock.yml index 2b1cb62..9c51835 100644 --- a/.github/workflows/update-flake-lock.yml +++ b/.forgejo/workflows/update-flake-lock.yml @@ -1,4 +1,5 @@ -name: update-flake-lock +name: "Update flake.lock" + on: workflow_dispatch: # allows manual triggering schedule: @@ -6,14 +7,15 @@ on: jobs: lockfile: - runs-on: ubuntu-latest + runs-on: nixos-unstable steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Install Nix - uses: cachix/install-nix-action@V27 - with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + + - name: Enable flakes + run: | + echo 'experimental-features = nix-command flakes' >>/etc/nix/nix.conf + - name: Update flake.lock uses: DeterminateSystems/update-flake-lock@v22 + if: false diff --git a/.github/actions/common-setup/action.yml b/.github/actions/common-setup/action.yml deleted file mode 100644 index 54e46cc..0000000 --- a/.github/actions/common-setup/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Setup Environment -inputs: - GITHUB_TOKEN: - required: true - description: "GitHub access token used to prevent GitHub's rate limit for unauthenticated requests" - CACHIX_SIGNING_KEY: # determines what node version to install - required: true - description: 'Cachix Signing Key' -runs: - using: "composite" - steps: - - - name: Installing Nix - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - extra_nix_config: | - access-tokens = github.com=${{ inputs.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@v12 - with: - name: nixos-search - signingKey: '${{ inputs.CACHIX_SIGNING_KEY }}' diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml deleted file mode 100644 index 76a52a9..0000000 --- a/.github/workflows/frontend.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: "Frontend: Build & Deploy to Netlify" -on: - workflow_dispatch: - pull_request: - paths: - - "flake.nix" - - "flake.lock" - - "frontend/**" - - "VERSION" - - push: - branches: - - main - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checking out the repository - uses: actions/checkout@v4 - - - name: Setup - uses: ./.github/actions/common-setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} - - - - - name: Building search.nixos.org - run: | - nix -vL build .#frontend - mkdir ./dist - cp -RL ./result/* ./dist/ - - - name: Deploy to Netlify - uses: nwtgck/actions-netlify@v3.0 - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - with: - production-branch: 'main' - production-deploy: ${{ github.event_name == 'push' }} - publish-dir: './dist' - github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: 'Deploy from GitHub Actions' - enable-pull-request-comment: true - overwrites-pull-request-comment: true - enable-commit-comment: false - enable-commit-status: true - if: github.repository_owner == 'NixOS'