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

Separate Bot User GitHub Tokens from regro GitHub Tokens #3326

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 3 additions & 4 deletions .github/workflows/bot-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
Comment on lines -48 to -49
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed BOT_TOKEN for install_bot_code.sh entirely everywhere because I could not find where it uses the token.


- name: run migrations
if: success() && ! env.CI_SKIP
Expand All @@ -60,6 +58,7 @@ jobs:
conda-forge-tick auto-tick
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
MEMORY_LIMIT_GB: 7
CF_TICK_GRAPH_DATA_BACKENDS: "${{ vars.CF_TICK_GRAPH_DATA_BACKENDS }}"
Expand All @@ -81,7 +80,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation: This only pushes to cf-graph so the permissions for regro are sufficient

REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -90,7 +89,7 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/bot-events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ jobs:
--no-clone-graph \
--no-clean-disk-space \
--no-pull-container
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: react to event
if: success() && ! env.CI_SKIP
Expand All @@ -85,7 +83,8 @@ jobs:
--event='${{ inputs.event }}' \
--uid='${{ inputs.uid }}'
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
BOT_TOKEN : ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
ytausch marked this conversation as resolved.
Show resolved Hide resolved
RUN_ID: ${{ github.run_id }}
# emptied at the beginning and end of each run, used by Python tempdir
TMPDIR: ${{ runner.temp }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-feedstocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: feedstocks
if: success() && ! env.CI_SKIP
Expand All @@ -64,7 +62,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -73,6 +71,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-make-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: make graph
if: success() && ! env.CI_SKIP
Expand All @@ -68,7 +66,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: trigger next job
Expand All @@ -85,6 +83,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-make-migrators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: make migrators
if: success() && ! env.CI_SKIP
Expand All @@ -66,7 +64,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: trigger next job
Expand All @@ -83,6 +81,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-migrate-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: update nodes
if: success() && ! env.CI_SKIP
Expand All @@ -76,7 +74,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -85,6 +83,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
9 changes: 4 additions & 5 deletions .github/workflows/bot-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: update prs
if: success() && ! env.CI_SKIP
Expand All @@ -63,6 +61,7 @@ jobs:
conda-forge-tick update-prs --job=${BOT_JOB} --n-jobs=${NUM_BOT_JOBS}
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
BOT_JOB: ${{ matrix.job_num }}
CF_TICK_GRAPH_DATA_BACKENDS: "${{ vars.CF_TICK_GRAPH_DATA_BACKENDS }}"
Expand All @@ -76,7 +75,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -85,7 +84,7 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}

Expand Down Expand Up @@ -129,6 +128,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
10 changes: 2 additions & 8 deletions .github/workflows/bot-pypi-mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,20 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: build import to package mapping
if: success() && ! env.CI_SKIP
run: |
pushd cf-graph

conda-forge-tick make-import-to-package-mapping
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: build pypi mapping
if: success() && ! env.CI_SKIP
run: |
pushd cf-graph

conda-forge-tick make-mappings
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: deploy
if: github.ref == 'refs/heads/main' && ! cancelled() && ! env.CI_SKIP
Expand All @@ -74,7 +68,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -83,6 +77,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-update-nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: update nodes
if: success() && ! env.CI_SKIP
Expand All @@ -77,7 +75,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -86,6 +84,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
8 changes: 2 additions & 6 deletions .github/workflows/bot-update-status-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: update status page
if: success() && ! env.CI_SKIP
run: |
pushd cf-graph

conda-forge-tick make-status-report
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: deploy
if: github.ref == 'refs/heads/main' && ! cancelled() && ! env.CI_SKIP
Expand All @@ -64,7 +60,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: trigger status page
Expand All @@ -81,6 +77,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
6 changes: 2 additions & 4 deletions .github/workflows/bot-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ jobs:
if: success() && ! env.CI_SKIP
run: |
source cf-scripts/autotick-bot/install_bot_code.sh
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}

- name: get versions
if: success() && ! env.CI_SKIP
Expand All @@ -71,7 +69,7 @@ jobs:
export RUN_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
conda-forge-tick deploy-to-github
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}

- name: bump on fail
Expand All @@ -80,6 +78,6 @@ jobs:
export ACTION_URL="https://github.com/regro/cf-scripts/actions/runs/${RUN_ID}"
python cf-scripts/autotick-bot/bump_bot_team.py
env:
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
REGRO_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
RUN_ID: ${{ github.run_id }}
ACTION_NAME: ${{ github.workflow }}
1 change: 1 addition & 0 deletions .github/workflows/tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
run: |
export TEST_BOT_TOKEN_VAL=unpassword
export BOT_TOKEN=${TEST_BOT_TOKEN_VAL}
export REGRO_TOKEN=${TEST_REGRO_TOKEN_VAL}
# note: we do not use pytest-xdist (-n auto) here for now because they interfere with hiding the
# MONGODB_CONNECTION_STRING sensitive environment variable
if [[ -f .test_durations ]]; then
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ If your migrator needs special configuration, you should write a new factory fun
- `TIMEOUT`: set to the number of seconds to wait before timing out the bot
- `RUN_URL`: set to the URL of the CI build (now set to a GHA run URL)
- `MEMORY_LIMIT_GB`: set to the memory limit in GB for the bot
- `BOT_TOKEN`: a GitHub token for the bot user
- `BOT_TOKEN`: a GitHub token for the bot user, having access to the `regro-cf-autotick-bot` GitHub account
- `REGRO_TOKEN`: a GitHub token that has permission to access the `regro` organization (currently identical with `BOT_TOKEN` in production but needed to use fine-grained tokens)
- `CF_FEEDSTOCK_OPS_CONTAINER_NAME`: the name of the container to use in the bot, otherwise defaults to `ghcr.io/regro/conda-forge-tick`
- `CF_FEEDSTOCK_OPS_CONTAINER_TAG`: set this to override the default container tag used in production runs, otherwise the value of `__version__` is used
- `CF_TICK_LIVE_TEST`: set to `true` to enable tests of the bot that require a working GitHub API token for `BOT_TOKEN`
Expand Down
2 changes: 1 addition & 1 deletion autotick-bot/bump_bot_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
today = datetime.today().strftime("%Y-%m-%d")
issue_title = f"[{today}] failed job {os.environ['ACTION_NAME']}"

gh = github.Github(os.environ["BOT_TOKEN"])
gh = github.Github(os.environ["REGRO_TOKEN"])
repo = gh.get_repo("regro/cf-scripts")

# find any issues from today, if any
Expand Down
4 changes: 2 additions & 2 deletions conda_forge_tick/all_feedstocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import tqdm

from conda_forge_tick.git_utils import github_client
from conda_forge_tick.git_utils import pygithub_client_bot_user

from .lazy_json_backends import dump, load

logger = logging.getLogger(__name__)


def get_all_feedstocks_from_github():
gh = github_client()
gh = pygithub_client_bot_user()

Check warning on line 14 in conda_forge_tick/all_feedstocks.py

View check run for this annotation

Codecov / codecov/patch

conda_forge_tick/all_feedstocks.py#L14

Added line #L14 was not covered by tests

org = gh.get_organization("conda-forge")
archived = set()
Expand Down
4 changes: 2 additions & 2 deletions conda_forge_tick/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ def _deploy_batch(*, files_to_add, batch, n_added, max_per_batch=200):
"git",
"push",
"https://{token}@github.com/{deploy_repo}.git".format(
token=env.get("BOT_TOKEN", ""),
token=env.get("REGRO_TOKEN", ""),
deploy_repo="regro/cf-graph-countyfair",
),
"master",
],
token=env.get("BOT_TOKEN", ""),
token=env.get("REGRO_TOKEN", ""),
)
_flush_io()
num_try += 1
Expand Down
1 change: 1 addition & 0 deletions conda_forge_tick/env_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SensitiveEnv:
"GITHUB_TOKEN",
"GH_TOKEN",
"BOT_TOKEN",
"REGRO_TOKEN",
"MONGODB_CONNECTION_STRING",
]

Expand Down
Loading
Loading