Skip to content

Commit

Permalink
Merge pull request #89 from rhobs/coleenquadros-patch-2
Browse files Browse the repository at this point in the history
Add Alertmanager workflow and additional step to update PR
  • Loading branch information
coleenquadros authored Jul 23, 2024
2 parents 3d674c1 + a75be9e commit aeaa28c
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 30 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/merge-acm-alertmanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ACM Alertmanager merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-alertmanager.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-alertmanager.yaml'

jobs:
alertmanager-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: prometheus/alertmanager
downstream: stolostron/prometheus-alertmanager
sandbox: rhobs/acm-prometheus-alertmanager
go-version: "1.22"
restore-upstream: >-
CHANGELOG.md
VERSION
go.mod
go.sum
assets-cmd: |
# Only compress assets if assets actually changed
# The git diff relies on gits remote naming. The merge-flow checks out
# $downstream as origin at the time of writing this code.
if ! git diff --exit-code origin/master ui/react-app; then
make assets-compress
find ui/react-app -type f -name '*.gz' -exec git add {} \;
git add ui/react-app/embed.go
git diff --cached --exit-code || git commit -s -m "[bot] assets: generate"
fi
secrets:
pr-app-id: ${{ secrets.ACM_APP_ID }}
pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }}
cloner-app-id: ${{ secrets.ACM_CLONER_APP_ID }}
cloner-app-private-key: ${{ secrets.ACM_CLONER_APP_PRIVATE_KEY }}
slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}
44 changes: 34 additions & 10 deletions .github/workflows/merge-acm-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
version: ${{ steps.org.outputs.downstream-version }}
compare-to: ${{ steps.upstream.outputs.release }}
lenient: false # fail if either of the versions cannot be parsed
- name: Check openshift fork status
- name: Check ACM stolostron fork status
id: fork-sync
run: |
SEMVER_RESULT="${{ steps.version.outputs.comparison-result }}"
Expand Down Expand Up @@ -196,25 +196,25 @@ jobs:
- name: Get auth token to create pull request for ${{ inputs.downstream }}
if: github.event_name != 'pull_request'
id: pr
uses: getsentry/action-github-app-token@v1
uses: getsentry/action-github-app-token@v3
with:
app_id: ${{ secrets.pr-app-id }}
private_key: ${{ secrets.pr-app-private-key }}
scope: ${{ steps.org.outputs.downstream }}
- name: Get auth token to push to ${{ inputs.sandbox }}
if: github.event_name != 'pull_request'
id: cloner
uses: getsentry/action-github-app-token@v1
uses: getsentry/action-github-app-token@v3
with:
app_id: ${{ secrets.cloner-app-id }}
private_key: ${{ secrets.cloner-app-private-key }}
scope: ${{ steps.org.outputs.sandbox }}
- name: Create Pull Request
if: github.event_name != 'pull_request'
uses: rhobs/create-pull-request@coleenquadros-patch-2
uses: rhobs/acm-create-pull-request@push-to-fork-token
id: create-pr
with:
title: "[bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
title: "[ACM Obs bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
body: |
## Description
This is an automated version bump from CI.
Expand Down Expand Up @@ -245,18 +245,42 @@ jobs:
token: ${{ steps.pr.outputs.token }}
push-to-fork: ${{ inputs.sandbox }}
push-to-fork-token: ${{ steps.cloner.outputs.token }}
- name: Check if PR exists using gh cli
# This step is a hack for the time being as the create-pull-request action has an issue with listing PRs across different named forks of the same repo.
# This is only to get the PR URL if it exists.
if: github.event_name != 'pull_request' && failure()
id: pr-exists
env:
GH_TOKEN: ${{ steps.pr.outputs.token }}
run: |
if [ "${{ steps.create-pr.outcome }}" != "success" ]; then
echo "${{ steps.create-pr.outcome }}"
PR_URL=$(gh pr list --json url --jq '.[0].url' --repo ${{ inputs.downstream }} --state open --head automated-updates-acm-${{ inputs.downstream-branch }})
if [ ! -z "$PR_URL" ]; then
echo "pr_exists=1" >> $GITHUB_OUTPUT
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
echo "PR exists >> $PR_URL"
else
echo "pr_exists=0" >> $GITHUB_OUTPUT
fi
fi
- name: Compose slack message body
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead')
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1' )
continue-on-error: true
id: slack-message
run: |
if [ "${{ steps.create-pr.outputs.pull-request-url }}" == "" ] || [ ${{ steps.fork-sync.outputs.status }} == "uptodate" ] || [ ${{ steps.fork-sync.outputs.status }} == "ahead" ] ; then
if [ "${{ steps.pr-exists.outputs.pr_exists }}" == "1" ]; then
PR_URL="${{ steps.pr-exists.outputs.pr_url }}"
else
PR_URL="${{ steps.create-pr.outputs.pull-request-url }}"
fi
if [ "${{ steps.fork-sync.outputs.status }}" == "uptodate" ] || [ "${{ steps.fork-sync.outputs.status }}" == "ahead" ]; then
echo "message=${{ inputs.downstream }} is already ${{ steps.fork-sync.outputs.status }} with tag ${{ steps.org.outputs.downstream-version }}." >> $GITHUB_OUTPUT
else
echo "message=PR ${{ steps.create-pr.outputs.pull-request-url }} has been ${{ steps.create-pr.outputs.pull-request-operation || 'updated' }}." >> $GITHUB_OUTPUT
echo "message=PR $PR_URL has been ${{ steps.create-pr.outputs.pull-request-operation || 'updated' }}." >> $GITHUB_OUTPUT
fi
- uses: 8398a7/action-slack@v3
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead')
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1')
continue-on-error: true
with:
status: custom
Expand All @@ -271,7 +295,7 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}
- uses: 8398a7/action-slack@v3
if: github.event_name != 'pull_request' && (failure() && steps.fork-sync.outputs.status != 'uptodate' && steps.fork-sync.outputs.status != 'ahead')
if: github.event_name != 'pull_request' && (failure() && steps.fork-sync.outputs.status != 'uptodate' && steps.fork-sync.outputs.status != 'ahead' && !(steps.pr-exists.outputs.pr_exists == '1'))
continue-on-error: true
with:
status: custom
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/merge-acm-kube-state-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ACM kube-state-metrics merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-kube-state-metrics.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-kube-state-metrics.yaml'

jobs:
kube-state-metrics-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: kubernetes/kube-state-metrics
downstream: stolostron/kube-state-metrics
sandbox: rhobs/acm-kube-state-metrics
go-version: "1.21"
restore-upstream: >-
CHANGELOG.md
VERSION
restore-downstream: >-
OWNERS
docs
secrets:
pr-app-id: ${{ secrets.ACM_APP_ID }}
pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }}
cloner-app-id: ${{ secrets.ACM_CLONER_APP_ID }}
cloner-app-private-key: ${{ secrets.ACM_CLONER_APP_PRIVATE_KEY }}
slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}
36 changes: 36 additions & 0 deletions .github/workflows/merge-acm-node-exporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ACM Node exporter merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-node-exporter.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-node-exporter.yaml'
jobs:
node-exporter-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: prometheus/node_exporter
downstream: stolostron/node-exporter
sandbox: rhobs/acm-node-exporter
go-version: "1.21"
restore-downstream: >-
OWNERS
restore-upstream: >-
CHANGELOG.md
VERSION
collector
go.mod
go.sum
secrets:
pr-app-id: ${{ secrets.ACM_APP_ID }}
pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }}
cloner-app-id: ${{ secrets.ACM_CLONER_APP_ID }}
cloner-app-private-key: ${{ secrets.ACM_CLONER_APP_PRIVATE_KEY }}
slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}
20 changes: 10 additions & 10 deletions .github/workflows/merge-acm-prometheus-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: ACM Prometheus Operator merger

on:
workflow_dispatch:
# schedule:
# - cron: '0 0 * * *' #@daily
# pull_request:
# paths:
# - '.github/workflows/merge-acm-flow.yaml'
# - '.github/workflows/merge-acm-prometheus-operator.yaml'
# push:
# paths:
# - '.github/workflows/merge-acm-flow.yaml'
# - '.github/workflows/merge-acm-prometheus-operator.yaml'
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-prometheus-operator.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-prometheus-operator.yaml'
jobs:
acm-prometheus-operator-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/merge-acm-prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: ACM Prometheus merger

on:
workflow_dispatch:
# schedule:
# - cron: '0 0 * * *' #@daily
# pull_request:
# paths:
# - '.github/workflows/merge-acm-flow.yaml'
# - '.github/workflows/merge-acm-prometheus.yaml'
# push:
# paths:
# - '.github/workflows/merge-acm-flow.yaml'
# - '.github/workflows/merge-acm-prometheus.yaml'
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-prometheus.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-prometheus.yaml'
jobs:
acm-prometheus-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/merge-acm-thanos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ACM Thanos merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-thanos.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-thanos.yaml'
jobs:
thanos-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: thanos-io/thanos
downstream: stolostron/thanos
sandbox: rhobs/acm-thanos
go-version: "1.22"
restore-downstream: >-
OWNERS
restore-upstream: >-
CHANGELOG.md
VERSION
docs
go.mod
go.sum
pkg
tutorials
.busybox-versions
.devcontainer
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 }}

0 comments on commit aeaa28c

Please sign in to comment.