From 705bdb1d5a24640e7929fec4091051e2e51422c3 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 5 Jun 2024 13:46:07 -0400 Subject: [PATCH 1/4] github actions workflows - wip --- ...-docker-image-and-publish-to-dockerhub.yml | 2 +- .github/workflows/on-release-published.yml | 42 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml index 669b306910..9a25d652a0 100644 --- a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml +++ b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout project uses: actions/checkout@v3 - name: Set engine version number in settings file - uses: ./.github/actions/set-engine-version-number-in-settings/action.yml + uses: ./.github/actions/set-engine-version-in-settings/action.yml with: working_directory: . engine_version_number: ${{ inputs.engine_version }} diff --git a/.github/workflows/on-release-published.yml b/.github/workflows/on-release-published.yml index 822ece8f48..e5f71b4e54 100644 --- a/.github/workflows/on-release-published.yml +++ b/.github/workflows/on-release-published.yml @@ -37,7 +37,7 @@ jobs: id: build-sign-and-package-plugin uses: ./.github/actions/build-sign-and-package-plugin with: - plugin_version_number: ${{ inputs.plugin_version_number }} + plugin_version_number: ${{ github.ref_name }} grafana_access_policy_token: ${{ env.GRAFANA_ACCESS_POLICY_TOKEN }} working_directory: grafana-plugin - name: Authenticate with GCS @@ -92,19 +92,33 @@ jobs: with: repo_secrets: | GITHUB_API_KEY=github_actions:github-api-key - - name: Merge Helm release PR - # yamllint disable rule:line-length + - name: Slice v from the tag + id: prepare-version-tag run: | - # Step 1. Fetch PRs from GitHub's API that're open and have a particular head ref indicative of a helm release PR - # API docs - https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests - # NOTE: ${github.ref_name:1} will slice off the "v" prefix from the tag + echo processed-tag="${GITHUB_REF_NAME:1}" >> $GITHUB_OUTPUT + - name: Find Helm release pull request + uses: juliangruber/find-pull-request-action@v1 + id: find-pull-request + with: + branch: helm-release/${{ steps.prepare-version-tag.outputs.processed-tag }} + - name: Merge pull Request + uses: juliangruber/merge-pull-request-action@v1 + with: + github-token: ${{ env.GITHUB_API_KEY }} + number: ${{ steps.find-pull-request.outputs.number }} + # - name: Fetch PRs from GitHub's API + # # yamllint disable rule:line-length + # run: | + # # Step 1. Fetch PRs from GitHub's API that're open and have a particular head ref indicative of a helm release PR + # # API docs - https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests + # # NOTE: ${github.ref_name:1} will slice off the "v" prefix from the tag - curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $${{ env.GITHUB_API_KEY }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/grafana/oncall/pulls?head=grafana:helm-release/$${{ github.ref_name }}:1}&state=open" > prs.json - cat prs.json + # curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $${GITHUB_API_KEY }" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/grafana/oncall/pulls?head=grafana:helm-release/$${GITHUB_REF_NAME}:1}&state=open" > prs.json + # cat prs.json - # Step 2. Extract the PR number from the first PR in the list to be able to pass that to the next API call - cat prs.json | jq -r ".[0].number" > pr_number.txt - cat pr_number.txt - # Step 3. Merge the PR (https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request) - cat pr_number.txt | xargs -r -I{pull_number} curl -L -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $${{ env.GITHUB_API_KEY }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/grafana/oncall/pulls/{pull_number}/merge" - # yamllint enable rule:line-length + # # Step 2. Extract the PR number from the first PR in the list to be able to pass that to the next API call + # cat prs.json | jq -r ".[0].number" > pr_number.txt + # cat pr_number.txt + # # Step 3. Merge the PR (https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request) + # cat pr_number.txt | xargs -r -I{pull_number} curl -L -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $${{ env.GITHUB_API_KEY }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/grafana/oncall/pulls/{pull_number}/merge" + # # yamllint enable rule:line-length From be0b00f2a835d7ae9388f5b960925cb8ee430bf0 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 5 Jun 2024 13:55:12 -0400 Subject: [PATCH 2/4] github actions workflows - wip --- .../build-engine-docker-image-and-publish-to-dockerhub.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml index 9a25d652a0..af9bbb9dfa 100644 --- a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml +++ b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout project uses: actions/checkout@v3 - name: Set engine version number in settings file - uses: ./.github/actions/set-engine-version-in-settings/action.yml + uses: ./.github/actions/set-engine-version-in-settings with: working_directory: . engine_version_number: ${{ inputs.engine_version }} From 2c0e02eba68dee7b3618d282e0e5af14455a930f Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 5 Jun 2024 14:07:12 -0400 Subject: [PATCH 3/4] update build-engine-docker-image github actions workflow --- .../build-engine-docker-image-and-publish-to-dockerhub.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml index af9bbb9dfa..72e4bf4cb8 100644 --- a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml +++ b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml @@ -23,6 +23,7 @@ jobs: - name: Checkout project uses: actions/checkout@v3 - name: Set engine version number in settings file + if: inputs.engine_version uses: ./.github/actions/set-engine-version-in-settings with: working_directory: . @@ -37,6 +38,7 @@ jobs: context: engine/ push: true platforms: linux/arm64/v8,linux/amd64 + repository: grafana/oncall tags: ${{ inputs.docker_image_tags }} build-args: | BUILDKIT_INLINE_CACHE=1 From e9e55f05b1e4b03b9f717de65ea03928b5a9fcb0 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 5 Jun 2024 14:10:58 -0400 Subject: [PATCH 4/4] update build-engine-docker-image github actions workflow --- .../build-engine-docker-image-and-publish-to-dockerhub.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml index 72e4bf4cb8..f13dcbed25 100644 --- a/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml +++ b/.github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml @@ -33,7 +33,7 @@ jobs: # TODO: change back to grafana/shared-workflows once this PR is merged # https://github.com/grafana/shared-workflows/pull/143 # uses: grafana/shared-workflows/actions/build-push-to-dockerhub@main - uses: joeyorlando/shared-workflows/actions/build-push-to-dockerhub@2cd8f06917d985a0f83176e6e439f69398c8d6e8 + uses: joeyorlando/shared-workflows/actions/build-push-to-dockerhub@a5b95e1419bc78276cf74f0f8246e25192345b94 with: context: engine/ push: true