Fix cleanup of nightly build workflow (#9441)

<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description

Fix cleanup of nightly build workflow
This commit is contained in:
Justin Ma 2023-06-15 11:11:08 +08:00 committed by GitHub
parent b5d43f1e20
commit b907bf355f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ on:
# branches:
# - main
schedule:
- cron: '0 3 * * *' # run at 3 AM UTC
- cron: '15 3 * * *' # run at 3:15 AM UTC
defaults:
run:
@ -21,11 +21,11 @@ defaults:
jobs:
prepare:
name: Prepare
if: github.repository == 'nushell/nightly'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
if: github.repository == 'nushell/nightly'
with:
ref: main
fetch-depth: 0
@ -34,6 +34,7 @@ jobs:
- name: Setup Nushell
uses: hustcer/setup-nu@v3
if: github.repository == 'nushell/nightly'
with:
version: 0.81.0
env:
@ -41,6 +42,7 @@ jobs:
- name: Prepare for Nightly Release
shell: nu {0}
if: github.repository == 'nushell/nightly'
run: |
cd $env.GITHUB_WORKSPACE
git checkout main
@ -182,12 +184,14 @@ jobs:
cleanup:
name: Cleanup
needs: release
if: github.repository == 'nushell/nightly'
runs-on: ubuntu-latest
steps:
# Sleep for 30 minutes, waiting for the release to be published
- name: Waiting for Release
run: sleep 1800
- name: Setup Nushell
if: ${{ always() }} # Always evaluates to true
uses: hustcer/setup-nu@v3
with:
version: 0.81.0
@ -198,7 +202,6 @@ jobs:
# Should only run in nushell/nightly repo
- name: Delete Older Releases
shell: nu {0}
if: ${{ always() }} # Always evaluates to true
run: |
let KEEP_COUNT = 10
let deprecated = (http get https://api.github.com/repos/nushell/nightly/releases | sort-by -r created_at | select tag_name id | range $KEEP_COUNT..)