Skip to content

Commit

Permalink
Add update.yml workflow (and initializing workflow init.yml) (#937)
Browse files Browse the repository at this point in the history
* Add update.yaml workflow

* Migrate conda/conda to update.yml

* Migrate conda/conda-build to update.yml

* Move release files into new templates directory

* Add template-files/config.yml

* Pre-commit edits

* Add comment about where to edit

* Minor edits

* Add placeholder for RELEASE.md

* Add initialization workflow to kickstart migration

* conda/governance as SSOT

* Always overwrite update.yml but don't overwrite config.yml

* Include recent HWUG.md improvements

* Restore conda & conda-build to old workflow

* Remove template-files/config.yml from infrastructure repo

* Create upstream PR to remove repo from sync.yml

* Update naming

* Use full length CoC.md

Co-authored-by: Jannis Leidel <[email protected]>
  • Loading branch information
kenodegard and jezdez authored Jul 31, 2024
1 parent d818da4 commit 7ecd6e0
Show file tree
Hide file tree
Showing 16 changed files with 840 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .github/sync/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ group:
- source: .github/PULL_REQUEST_TEMPLATE/with_releases.md
dest: .github/PULL_REQUEST_TEMPLATE.md
# news snippet template
- source: .github/sync/TEMPLATE
- source: templates/releases/TEMPLATE
dest: news/TEMPLATE
# projects without releases
- repos: |
Expand All @@ -100,10 +100,10 @@ group:
conda/pycosat
files:
# rever config
- source: .github/sync/rever.xsh
- source: templates/releases/rever.xsh
dest: rever.xsh
# release docs
- source: .github/sync/RELEASE.md
- source: templates/releases/RELEASE.md
dest: RELEASE.md
# Code of Conduct sync
- repos: |
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Initiate Repository

on:
workflow_dispatch:
inputs:
org:
description: The GitHub organization within which the repository is located.
required: true
type: choice
options:
- conda
- conda-incubator
default: conda
repo:
description: The repository to push the update workflow to.
required: true

jobs:
push:
if: >-
!github.event.repository.fork
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
# repository: ${{ github.repository }}
path: upstream

- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
repository: ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}
path: downstream

- name: Configure git user
run: |
git config user.name 'Conda Bot'
git config user.email '[email protected]'
- name: (upstream) Remove repository from sync.yml
run: sed -i '\%${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}$%d' upstream/.github/sync/config.yml

- name: (upstream) Commit changes
run: cd upstream && git add . && git commit --message "🤖 updated file(s)" || true

- name: (upstream) Create fork
run: cd upstream && echo UPSTREAM=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}

- name: (upstream) Create PR
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
push-to-fork: ${{ env.UPSTREAM }}
token: ${{ secrets.SYNC_TOKEN }}
branch: init-${{ github.event.inputs.org }}-${{ github.event.inputs.repo }}
delete-branch: true
title: 🤖 Init ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}
body: |
[init.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/init.yml
Removes ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }} from the `sync.yml` workflow.
This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}.
###### Auto-generated by the [`init.yml`][init.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
- name: (downstream) Copy (overwrite) update.yml
run: cp -f upstream/.github/workflows/update.yml downstream/.github/workflows/update.yml || true

- name: (downstream) Copy (do not overwrite) config.yml
run: cp -n upstream/templates/config.yml downstream/.github/template-files/config.yml || true

- name: (downstream) Commit changes
run: cd downstream && git add . && git commit --message "🤖 updated file(s)" || true

- name: (downstream) Create fork
run: cd downstream && echo DOWNSTREAM=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}

- name: (downstream) Create PR
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
push-to-fork: ${{ env.DOWNSTREAM }}
token: ${{ secrets.SYNC_TOKEN }}
branch: init
delete-branch: true
title: 🤖 Init
body: |
[init.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/init.yml
This adds the `update.yml` workflow (and the accompanying `config.yml`) to this repository to enable regular syncing and templating of standard files (e.g., Code of Conduct file, CLA bot workflow, stale bot workflow, etc.).
This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}.
###### Auto-generated by the [`update.yml`][update.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
109 changes: 109 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Update Repository

on:
# every Sunday at 00:36 UTC
# https://crontab.guru/#36_2_*_*_0
schedule:
- cron: 36 2 * * 0

workflow_dispatch:

issue_comment:
types:
- created

jobs:
update:
if: >-
!github.event.repository.fork
&& (
github.event_name == 'schedule'
|| github.event_name == 'workflow_dispatch'
|| (
github.event_name == 'issue_comment'
&& github.event.issue.pull_request
&& (
github.event.comment.body == '@conda-bot render'
|| github.event.comment.body == '@conda-bot recreate'
)
)
)
runs-on: ubuntu-latest
steps:
- if: github.event_name == 'issue_comment'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes
reactions-edit-mode: replace
token: ${{ secrets.SYNC_TOKEN }}

- if: github.event.comment.body == '@conda-bot render'
name: Configure git origin
run: |
echo REPOSITORY=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.repo.full_name') >> $GITHUB_ENV
echo REF=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.ref') >> $GITHUB_ENV
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
repository: ${{ env.REPOSITORY || github.repository }}
ref: ${{ env.REF || '' }}

- name: Configure git user
run: |
git config user.name 'Conda Bot'
git config user.email '[email protected]'
- uses: conda/actions/combine-durations@976289d0cfd85139701b26ddd133abdd025a7b5f # v24.5.0

- uses: conda/actions/template-files@976289d0cfd85139701b26ddd133abdd025a7b5f # v24.5.0

- name: Commit changes
run: git add . && git commit --message "🤖 updated file(s)" || true

- if: github.event.comment.body != '@conda-bot render'
name: Create fork
run: echo FORK=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}

- if: github.event.comment.body != '@conda-bot render'
id: create
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
push-to-fork: ${{ env.FORK }}
token: ${{ secrets.SYNC_TOKEN }}
branch: update
delete-branch: true
title: 🤖 Update
body: |
[update.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/update.yml
Your friendly repository updater.
This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}.
<details>
<summary>Commands</summary>
Trigger actions by commenting on this PR:
- `@conda-bot render` will run rendering workflows and commit and push any changes to this PR
- `@conda-bot recreate` will recreate this PR, overwriting any edits that have been made to it
</details>
###### Auto-generated by the [`update.yml`][update.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
- if: github.event.comment.body == '@conda-bot render'
id: update
name: Push changes
run: git push --force-with-lease

- if: always() && github.event_name == 'issue_comment'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ github.event.comment.id }}
reactions: ${{ (steps.create.conclusion == 'success' || steps.update.conclusion == 'success') && 'hooray' || 'confused' }}
reactions-edit-mode: replace
token: ${{ secrets.SYNC_TOKEN }}
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ repos:
# ensure syntaxes are valid
- id: check-toml
- id: check-yaml
# exclude files that contain jinja templating directives
exclude: |
(?x)^(
templates/issues/bug.yml
)
# catch git merge/rebase problems
- id: check-merge-conflict
- repo: local
Expand Down Expand Up @@ -39,6 +44,11 @@ repos:
- id: yamlfmt
# ruamel.yaml doesn't line wrap correctly (?) so set width to 1M to avoid issues
args: [--mapping=2, --offset=2, --sequence=4, --width=1000000, --implicit_start]
# exclude files that contain jinja templating directives
exclude: |
(?x)^(
templates/issues/bug.yml
)
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Conda Organization Code of Conduct

> [!NOTE]
> Below is the short version of our CoC, see the long version [here](https://github.com/conda-incubator/governance/blob/main/CODE_OF_CONDUCT.md).
> Below is the short version of our CoC, see the long version [here](https://github.com/conda/governance/blob/main/CODE_OF_CONDUCT.md).
# The Short Version

Expand Down
Loading

0 comments on commit 7ecd6e0

Please sign in to comment.