Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep workflows enabled #118

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/keep-workflows-enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow is intended to keep scheduled GH Action workflows enabled
# as a work-around for scheduled workflows being automatically disabled when
# no repository activity has occurred in 60 days.
name: Keep workflows enabled

on:
schedule:
# Scheduled to run at 4pm UTC (8am PST) on the first day of the month
- cron: '0 16 1 * *'

workflow_dispatch:

jobs:
enable-workflow:
permissions:
actions: write
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_WORKFLOW_DISPATCH }}
name: "${{ matrix.repo }}:${{ matrix.workflow }}"
strategy:
fail-fast: false
matrix:
include:
- { repo: .github, workflow: keep-workflows-enabled.yaml }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

box

- { repo: augur, workflow: ci.yaml }
- { repo: avian-flu, workflow: ingest-to-phylogenetic-ncbi.yaml }
- { repo: cli, workflow: ci.yaml }
- { repo: cli, workflow: standalone-installers.yaml }
- { repo: conda-base, workflow: installation.yaml }
- { repo: dengue, workflow: ingest-to-phylogenetic.yaml }
- { repo: forecasts-ncov, workflow: update-ncov-case-counts.yaml }
- { repo: lassa, workflow: ci.yaml }
- { repo: lassa, workflow: ingest-to-phylogenetic.yaml }
- { repo: measles, workflow: ingest-to-phylogenetic.yaml }
- { repo: mpox, workflow: fetch-and-ingest.yaml }
- { repo: ncov, workflow: rebuild-100k.yml }
- { repo: ncov-ingest, workflow: fetch-and-ingest-genbank-master.yml }
- { repo: ncov-ingest, workflow: fetch-and-ingest-gisaid-master.yml }
- { repo: nextstrain.org, workflow: index-resources.yml }
- { repo: nextstrain.org, workflow: remind-to-promote.yml }
- { repo: nipah, workflow: ingest-to-phylogenetic.yaml }
- { repo: oropouche, workflow: ingest-to-phylogenetic.yaml }
- { repo: rabies, workflow: ingest-to-phylogenetic.yaml }
- { repo: rsv, workflow: fetch-and-ingest.yaml }
- { repo: rsv, workflow: rebuild.yaml }
- { repo: seasonal-cov, workflow: ingest-to-phylogenetic.yaml }
- { repo: status, workflow: ci.yaml }
- { repo: WNV, workflow: ingest-to-phylogenetic.yaml }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely clear to me why this failed for WNV:

gh: Must have admin rights to Repository. (HTTP 403)
{"message":"Must have admin rights to Repository.","documentation_url":"https://docs.github.com/rest/actions/workflows#enable-a-workflow","status":"403"}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, nextstrain/core (which includes nextstrain-bot user) only has read access for the WNV repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated nextstrain/core to admin access for WNV repo (after confirmation on Slack) and the job succeeded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error message is misleading and admin is not strictly necessary (and should be avoided if possible). The API call for augur's ci.yaml was successful with write on that repo. Can we check if this works with write on WNV?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right! I set nextstrain/core to write access for WNV repo and the job succeeded

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The access requirements are defined here, but it's not super clear.

permissions:
actions: write
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_WORKFLOW_DISPATCH }}

Suggestion: summarize with a comment along the lines of "ensure nextstrain-bot has write access to all repos included in the matrix" so in the future we're less likely to see the misleading error message.

- { repo: zika, workflow: ingest-to-phylogenetic.yaml }
Comment on lines +24 to +49
Copy link
Member

@tsibley tsibley Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much prefer to query these (e.g. from GitHub's API) rather than hardcode them all here... (but we don't need to do that now if you aren't so inclined)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, it's a "feature" to allow explicit opt-in of workflows 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revisit when I have the appetite: #119


runs-on: ubuntu-latest
steps:
- run: |
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/nextstrain/${{matrix.repo}}/actions/workflows/${{matrix.workflow}}/enable
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ See also GitHub's [documentation on starter workflows](https://docs.github.com/e

- CI tests for the actions and reusable workflows above
([workflow](.github/workflows/ci.yaml))
- Central workflow to keep all scheduled GH Action workflows enabled
([workflow](.github/workflows/keep-workflows-enabled.yaml))


## Workflow scripts
Expand Down
Loading