From 705bdb1d5a24640e7929fec4091051e2e51422c3 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 5 Jun 2024 13:46:07 -0400 Subject: [PATCH] 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 669b3069..9a25d652 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 822ece8f..e5f71b4e 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