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

Add ACM Grafana config #97

Merged
merged 3 commits into from
Sep 23, 2024
Merged
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
24 changes: 16 additions & 8 deletions .github/workflows/merge-acm-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
required: false
default: ''
type: string
go-mod-tidy:
description: Run `go mod tidy` after a merge
required: false
default: true
type: boolean
secrets:
cloner-app-id:
description: Github ID of cloner app
Expand Down Expand Up @@ -82,9 +87,11 @@
- name: Find github org name from repo name
id: org
run: |
echo "upstream=$(dirname ${{ inputs.upstream }})" >> $GITHUB_OUTPUT
echo "downstream=$(dirname ${{ inputs.downstream }})" >> $GITHUB_OUTPUT
echo "sandbox=$(dirname ${{ inputs.sandbox }})" >> $GITHUB_OUTPUT
{
echo "upstream=$(dirname ${{ inputs.upstream }})"
echo "downstream=$(dirname ${{ inputs.downstream }})"
echo "sandbox=$(dirname ${{ inputs.sandbox }})"
} >> "$GITHUB_OUTPUT"
DOWNSTREAM_VERSION=$(curl -sL "https://raw.githubusercontent.com/${{ inputs.downstream }}/${{ inputs.downstream-branch }}/VERSION")
if [[ "${DOWNSTREAM_VERSION}" =~ ^$|"404: Not Found" ]]; then
# Strip the trailing URL from the expression.
Expand All @@ -101,7 +108,7 @@
exit 1
fi
fi
echo "downstream-version=${DOWNSTREAM_VERSION}" >> $GITHUB_OUTPUT
echo "downstream-version=${DOWNSTREAM_VERSION}" >> "$GITHUB_OUTPUT"
- uses: madhead/semver-utils@latest
id: version
with:
Expand All @@ -114,14 +121,14 @@
SEMVER_RESULT="${{ steps.version.outputs.comparison-result }}"
echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.release }}"
if [ "${SEMVER_RESULT}" == "<" ]; then
echo "status=outdated" >> $GITHUB_OUTPUT
echo "status=outdated" >> "$GITHUB_OUTPUT"
echo "::notice::downstream outdated"
elif [ "${SEMVER_RESULT}" == "=" ]; then
echo "status=uptodate" >> $GITHUB_OUTPUT
echo "status=uptodate" >> "$GITHUB_OUTPUT"
echo "::notice::downstream up-to-date"
exit 0
else
echo "status=ahead" >> $GITHUB_OUTPUT
echo "status=ahead" >> "$GITHUB_OUTPUT"
echo "::notice::downstream ahead"
exit 0
fi
Expand All @@ -139,7 +146,7 @@
- name: Merge with upstream ${{ steps.upstream.outputs.release }} tag
id: merge
run: |
git merge -X theirs refs/tags/${{ steps.upstream.outputs.release }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT
git merge -X theirs refs/tags/${{ steps.upstream.outputs.release }} --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 Down Expand Up @@ -186,6 +193,7 @@
with:
node-version: ${{ inputs.node-version }}
- name: go mod tidy + vendor
if: ${{ inputs.go-mod-tidy }}
run: |
go mod tidy
git add go.mod go.sum
Expand Down Expand Up @@ -252,7 +260,7 @@
id: pr-exists
env:
GH_TOKEN: ${{ steps.pr.outputs.token }}
run: |

Check failure on line 263 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2236:style:4:10: Use -n instead of ! -z [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:263:9: shellcheck reported issue in this script: SC2236:style:4:10: Use -n instead of ! -z [shellcheck]

Check failure on line 263 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:5:29: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:263:9: shellcheck reported issue in this script: SC2086:info:5:29: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 263 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:6:32: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:263:9: shellcheck reported issue in this script: SC2086:info:6:32: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 263 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:263:9: shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting [shellcheck]
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 }})
Expand All @@ -268,7 +276,7 @@
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: |

Check failure on line 279 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:7:149: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:279:9: shellcheck reported issue in this script: SC2086:info:7:149: Double quote to prevent globbing and word splitting [shellcheck]

Check failure on line 279 in .github/workflows/merge-acm-flow.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:9:109: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/merge-acm-flow.yaml:279:9: shellcheck reported issue in this script: SC2086:info:9:109: Double quote to prevent globbing and word splitting [shellcheck]
if [ "${{ steps.pr-exists.outputs.pr_exists }}" == "1" ]; then
PR_URL="${{ steps.pr-exists.outputs.pr_url }}"
else
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/merge-acm-grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: ACM Grafana merger

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' #@weekly
pull_request:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-grafana.yaml'
push:
paths:
- '.github/workflows/merge-acm-flow.yaml'
- '.github/workflows/merge-acm-grafana.yaml'
jobs:
grafana-merge:
uses: ./.github/workflows/merge-acm-flow.yaml
with:
upstream: grafana/grafana
downstream: stolostron/grafana
sandbox: rhobs/acm-grafana
go-version: "1.22"
node-version: "20"
go-mod-tidy: false
restore-downstream: >-
OWNERS
restore-upstream: >-
.drone.yml
CHANGELOG.md
docs
go.mod
go.sum
go.work
go.work.sum
pkg
lerna.json
package.json
packages
public/app/
yarn.lock
assets-cmd: |
# get rid of old assets as new filenames are generated
rm -rf ./public/build/

# generate nodejs files, using docker since it appears to be problematic doing
# it directly in the github action runner.
docker build --target js-builder -t grafana-js-build .
docker create --name grafana-jsbuild grafana-js-build:latest
docker cp grafana-jsbuild:/tmp/grafana/public/build ./public/
docker rm grafana-jsbuild

# Generate go files with wire
go mod download
go run ./pkg/build/wire/cmd/wire/main.go gen -tags oss ./pkg/server

# Commit assets
git add pkg/server/wire_gen.go ./public/build ./public/app/plugins/datasource/*/dist/*
git diff --cached --exit-code || git commit -s -m "[bot] assets: generate"
downstream-version-expression: |
sed -n -E 's/^.*\"version\": *\"([0-9]+\.[0-9]+\.[0-9]+)\".*$/v\1/p' https://raw.githubusercontent.com/stolostron/grafana/release-2.12/package.json
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 }}
Loading