Skip to content

wip: no review needed #81

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
51 changes: 35 additions & 16 deletions .github/workflows/merge-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: Upstream repo path in owner/repo format
required: true
type: string
upstream-version-regex:
description: Regex that the upstream version should match
required: false
default: '^v\d+\.\d+\.\d+$'
type: string
downstream:
description: Downstream repo path in owner/repo format
required: true
Expand All @@ -24,6 +29,11 @@ on:
description: Sandbox repo path in owner/repo format. Used as a base to create PR against downstream.
required: true
type: string
sandbox-branch-prefix:
description: Prefix fot the PR branch
required: false
default: 'automated-updates'
type: string
restore-upstream:
description: List of files to be reset using upstream content on merge conflict.
required: false
Expand All @@ -44,6 +54,16 @@ on:
required: false
default: ''
type: string
pr-labels:
description: Labels to add to the PR
required: false
default: ''
type: string
pr-title-prefix:
description: Prefix for the PR title
required: false
default: ''
type: string
secrets:
cloner-app-id:
description: Github ID of cloner app
Expand All @@ -67,14 +87,12 @@ jobs:
name: Perform merge operation
steps:
- name: Get latest upstream tag
uses: oprypin/find-latest-tag@v1
id: upstream
run: |
UPSTREAM_VERSION=$(curl --fail --silent "https://api.github.com/repos/${{ inputs.upstream }}/releases/latest" | jq -r '.tag_name')
if [ "$UPSTREAM_VERSION" == "" ]; then
echo "upstream-version is invalid" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "release=${UPSTREAM_VERSION}" >> "$GITHUB_OUTPUT"
with:
repository: ${{ inputs.upstream }}
releases-only: true
regex: ${{ inputs.upstream-version-regex }}
- name: Find github org name from repo name
id: org
run: |
Expand Down Expand Up @@ -104,13 +122,13 @@ jobs:
id: version
with:
version: ${{ steps.org.outputs.downstream-version }}
compare-to: ${{ steps.upstream.outputs.release }}
compare-to: ${{ steps.upstream.outputs.tag }}
lenient: false # fail if either of the versions cannot be parsed
- name: Check openshift fork status
id: fork-sync
run: |
SEMVER_RESULT="${{ steps.version.outputs.comparison-result }}"
echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.release }}"
echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.tag }}"
if [ "${SEMVER_RESULT}" == "<" ]; then
echo "status=outdated" >> $GITHUB_OUTPUT
echo "::notice::downstream outdated"
Expand All @@ -134,10 +152,10 @@ jobs:
git config user.email 'github-actions[bot]@users.noreply.github.com'
git config --global core.editor "/bin/true"
git fetch https://github.com/${{ inputs.upstream }} --tags
- name: Merge with upstream ${{ steps.upstream.outputs.release }} tag
- name: Merge with upstream ${{ steps.upstream.outputs.tag }} tag
id: merge
run: |
git merge refs/tags/${{ steps.upstream.outputs.release }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT
git merge refs/tags/${{ steps.upstream.outputs.tag }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT
- name: Resolve conflict using upstream contents
if: ${{ steps.merge.outputs.MERGE_CONFLICT == 'true' && inputs.restore-upstream != ''}}
run: |
Expand All @@ -159,9 +177,9 @@ jobs:
run: git merge --continue
- name: Add VERSION file if not present
run: |
is_version_file_present_upstream=$(git ls-tree ${{ steps.upstream.outputs.release }} | grep VERSION || true)
is_version_file_present_upstream=$(git ls-tree ${{ steps.upstream.outputs.tag }} | grep VERSION || true)
# All tags use the vX.Y.Z format currently.
version_from_tag=$(echo ${{ steps.upstream.outputs.release }} | sed -e "s/^v//")
version_from_tag=$(echo ${{ steps.upstream.outputs.tag }} | sed -e "s/^v//")
# Perform check only if both remotes have the VERSION file.
if [ -n "$is_version_file_present_upstream" ] && [ -f VERSION ]; then
version_from_file=$(cat VERSION)
Expand Down Expand Up @@ -224,15 +242,15 @@ jobs:
uses: rhobs/create-pull-request@v3
id: create-pr
with:
title: "[bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
title: "${{ inputs.pr-title-prefix }}[bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.tag }}"
body: |
## Description
This is an automated version bump from CI.
The logs for this run can be found [in the syncbot repo actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
If you wish to perform this manually, execute the following commands from ${{ inputs.downstream }} repo:
```
git fetch https://github.com/${{ inputs.upstream }} --tags
if ! git merge refs/tags/${{ steps.upstream.outputs.release }} --no-edit; then
if ! git merge refs/tags/${{ steps.upstream.outputs.tag }} --no-edit; then
git checkout --theirs ${{ inputs.restore-upstream }}
git checkout --ours ${{ inputs.restore-downstream }}
git add ${{ inputs.restore-upstream }} ${{ inputs.restore-downstream }}
Expand All @@ -247,10 +265,11 @@ jobs:
git diff --cached --exit-code || git commit -s -m "[bot] update rh-manifest.txt"
fi
```
labels: ${{ inputs.pr-labels }}
author: 'github-actions[bot]<github-actions[bot]@users.noreply.github.com>'
committer: 'github-actions[bot]<github-actions[bot]@users.noreply.github.com>'
signoff: true
branch: automated-updates-${{ inputs.downstream-branch }}
branch: ${{ inputs.sandbox-branch-prefix }}-${{ inputs.downstream-branch }}
delete-branch: true
token: ${{ steps.pr.outputs.token }}
push-to-fork: ${{ inputs.sandbox }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/merge-prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
uses: ./.github/workflows/merge-flow.yaml
with:
upstream: prometheus/prometheus
upstream-version-regex: ${{ inputs.upstream-version-regex }}

Check failure on line 20 in .github/workflows/merge-prometheus.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 property "upstream-version-regex" is not defined in object type {} [expression] Raw Output: e:.github/workflows/merge-prometheus.yaml:20:35: property "upstream-version-regex" is not defined in object type {} [expression]
downstream: openshift/prometheus
sandbox: rhobs/prometheus
sandbox-branch-prefix: ${{ inputs.sandbox-branch-prefix }}

Check failure on line 23 in .github/workflows/merge-prometheus.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 property "sandbox-branch-prefix" is not defined in object type {} [expression] Raw Output: e:.github/workflows/merge-prometheus.yaml:23:34: property "sandbox-branch-prefix" is not defined in object type {} [expression]
pr-labels: ${{ inputs.pr-labels }}

Check failure on line 24 in .github/workflows/merge-prometheus.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 property "pr-labels" is not defined in object type {} [expression] Raw Output: e:.github/workflows/merge-prometheus.yaml:24:22: property "pr-labels" is not defined in object type {} [expression]
pr-title-prefix: ${{ inputs.pr-title-prefix }}

Check failure on line 25 in .github/workflows/merge-prometheus.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 property "pr-title-prefix" is not defined in object type {} [expression] Raw Output: e:.github/workflows/merge-prometheus.yaml:25:28: property "pr-title-prefix" is not defined in object type {} [expression]
restore-upstream: >-
CHANGELOG.md
VERSION
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test-prometheus-rc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Prometheus rc versions tester

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' #@daily
pull_request:
paths:
- '.github/workflows/merge-flow.yaml'
- '.github/workflows/merge-prometheus.yaml'
- '.github/workflows/test-prometheus-rc.yaml'
push:
paths:
- '.github/workflows/merge-flow.yaml'
- '.github/workflows/merge-prometheus.yaml'
- '.github/workflows/test-prometheus-rc.yaml'
jobs:
prometheus-test-rc:
uses: ./.github/workflows/merge-prometheus.yaml

Check failure on line 19 in .github/workflows/test-prometheus-rc.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 error while parsing reusable workflow "./.github/workflows/merge-prometheus.yaml": "workflow_call" event trigger is not found in "on:" at line:4, column:3 [workflow-call] Raw Output: e:.github/workflows/test-prometheus-rc.yaml:19:11: error while parsing reusable workflow "./.github/workflows/merge-prometheus.yaml": "workflow_call" event trigger is not found in "on:" at line:4, column:3 [workflow-call]
with:
upstream-version-regex: '^v\d+\.\d+\.\d+-rc\.\d+$'
sandbox-branch-prefix: automated-tests-rc
# The PRs are only meant to run tests
pr-labels: 'do-not-merge/hold,ok-to-test'
pr-title-prefix: 'FOR TESTS ONLY: '

secrets:
pr-app-id: ${{ secrets.APP_ID }}
pr-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
cloner-app-id: ${{ secrets.CLONER_APP_ID }}
cloner-app-private-key: ${{ secrets.CLONER_APP_PRIVATE_KEY }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading