Skip to content

Commit

Permalink
add github workflow to pin integrations core
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 25, 2025
1 parent fc8851b commit 5746fcf
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pin_integrations_core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pin Integrations Core

on:
workflow_dispatch:
schedule:
- cron: '0 4 * * 1,3,5' # Run on Monday, Wednesday at 4:00 UTC
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions: {}

jobs:
pin_integrations_core:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
sparse-checkout: 'tasks'
persist-credentials: false

- name: Install python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version-file: .python-version
cache: "pip"

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r tasks/libs/requirements-github.txt
pip install -r tasks/requirements_release_tasks.txt
- name: Pin integrations Core
run: |
inv release.pin-integrations-core
1 change: 1 addition & 0 deletions tasks/libs/ciproviders/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ def create_release_pr(title, base_branch, target_branch, version, changelog_pr=F
pr_body="",
base_branch=base_branch,
target_branch=target_branch,
draft=True
)

if not pr:
Expand Down
47 changes: 47 additions & 0 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from tasks.libs.releasing.json import (
DEFAULT_BRANCHES,
DEFAULT_BRANCHES_AGENT6,
RELEASE_JSON_FIELDS_TO_UPDATE,
UNFREEZE_REPOS,
_get_release_json_value,
_save_release_json,
Expand Down Expand Up @@ -1279,3 +1280,49 @@ def check_previous_agent6_rc(ctx):
payload = {'message': err_msg}
send_slack_msg(ctx, payload, os.environ.get("SLACK_DATADOG_AGENT_CI_WEBHOOK"))
raise Exit(message=err_msg, code=1)


@task
def pin_integrations_core(ctx):
commit_hash = ctx.run(
rf'git ls-remote https://github.com/DataDog/integrations-core HEAD',
hide=True,
).stdout.strip().split()[0]

current = current_version(ctx, 7)
current.rc = False
current.devel = False

rj = load_release_json()

for nightly in ["nightly", "nightly-a7"]:
rj[nightly][RELEASE_JSON_FIELDS_TO_UPDATE[0]] = commit_hash

_save_release_json(rj)

main_branch = "main"
pin_integrations_core_branch = f"pin-integrations-core"
ctx.run(f"git checkout -b {pin_integrations_core_branch}")
ctx.run("git add release.json")

commit_message = f"Update integrations core to HEAD"
ok = try_git_command(ctx, f"git commit -m '{commit_message}'")
if not ok:
raise Exit(
color_message(
f"Could not create commit. Please commit manually with:\ngit commit -m {commit_message}\n, push the {pin_integrations_core_branch} branch and then open a PR against {main_branch}.",
"red",
),
code=1,
)

if not ctx.run(f"git push --set-upstream origin {pin_integrations_core_branch}", warn=True):
raise Exit(
color_message(
f"Could not push branch {pin_integrations_core_branch} to the upstream 'origin'. Please push it manually and then open a PR against {main_branch}.",
"red",
),
code=1,
)

create_release_pr(commit_message, main_branch, pin_integrations_core_branch, current)

0 comments on commit 5746fcf

Please sign in to comment.