Fix cron workflow (#108)

This commit is contained in:
Rok Garbas 2020-06-19 20:16:11 +02:00 committed by GitHub
parent 3ecce08a94
commit b06bac6187
Failed to generate hash of commit
3 changed files with 40 additions and 2 deletions

View file

@ -1,23 +1,59 @@
name: "Hourly import channel to Elasticsearch" name: "Hourly import channel to Elasticsearch"
on: on:
schedule: schedule:
- cron: '0 * * * *' - cron: '0 * * * *'
jobs: jobs:
hourly-import-channel: hourly-import-channel:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: true
matrix: matrix:
channel: channel:
- unstable - unstable
- 20.03 - 20.03
- 19.09 - 19.09
fail-fast: true
env:
S3_URL: s3://nix-releases/nixpkgs
steps: steps:
- name: Checking out the repository - name: Checking out the repository
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for latest evaluation in ${{ matrix.channel }} channel
run: |
sudo apt-get install -y awscli
if [ "${{ matrix.channel }}" = "unstable" ]; then
RELEASE=$(aws s3 ls --no-sign-request "$S3_URL/" | grep "/$" | cut -d" " -f29 | sort | tail -1 | sed 's|/||')
else
RELEASE=$(aws s3 ls --no-sign-request "$S3_URL/" | grep "nixpkgs-${{ matrix.channel }}pre" | grep "/$" | cut -d" " -f29 | sort | tail -1 | sed 's|/||')
fi
aws s3 cp --no-sign-request "$S3_URL/$RELEASE/src-url" ./
echo "::set-env name=EVAL_ID::$(cat src-url | cut -c30-)"
- name: Cache ${{ matrix.channel }} channel builds
id: eval-cache
uses: actions/cache@v2
with:
path: ./eval-cache
key: eval-cache-${{ env.EVAL_ID }}
- name: Download latest builds for ${{ matrix.channel }} channel (if needed)
if: steps.eval-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ./eval-cache
cp ./src-url ./eval-cache/
curl -H "Content-Type: application/json" "$(cat ./eval-cache/src-url)/builds" -o ./eval-cache/builds.json
- name: Installing Nix - name: Installing Nix
uses: cachix/install-nix-action@v8 uses: cachix/install-nix-action@v8
@ -35,5 +71,6 @@ jobs:
- name: Import ${{ matrix.channel }} channel - name: Import ${{ matrix.channel }} channel
run: | run: |
cp ./eval-cache/builds.json ./eval-${{ env.EVAL_ID }}.json
./result/bin/import-channel --es-url ${{ secrets.ELASTICSEARCH_URL }} --channel ${{ matrix.channel }} -vvv ./result/bin/import-channel --es-url ${{ secrets.ELASTICSEARCH_URL }} --channel ${{ matrix.channel }} -vvv
if: github.repository == 'NixOS/nixos-search' if: github.repository == 'NixOS/nixos-search'

1
.gitignore vendored
View file

@ -32,3 +32,4 @@ package-lock.json
result result
scripts/eval-* scripts/eval-*
eval-* eval-*
src-url

View file

@ -35,7 +35,7 @@ CHANNELS = {
"options": "nixos/19.09/nixos-19.09.", "options": "nixos/19.09/nixos-19.09.",
}, },
"20.03": { "20.03": {
"packages": "nixpkgs/nixpkgs-19.09pre", "packages": "nixpkgs/nixpkgs-20.03pre",
"options": "nixos/20.03/nixos-20.03.", "options": "nixos/20.03/nixos-20.03.",
}, },
} }