A platform for community discussion. Free, open, simple.
DEV: Use new github `job.check_run_id` workflow expression (#37953)
David Taylor63cfdcb7b7b8
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 8d7df75d518..cc24868e07a 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -389,23 +389,16 @@ jobs:echo "exists=false" >> $GITHUB_OUTPUTfi- - name: Fetch Job ID- id: fetch-job-id- if: steps.check-flaky-spec-report.outputs.exists == 'true'- run: |- job_id=$(ruby script/get_github_workflow_run_job_id.rb ${{ github.run_id }} ${{ github.run_attempt }} '${{ matrix.target }} ${{ matrix.build_type }}${{ (matrix.target == 'core' && matrix.build_type == 'frontend' && format(' ({0})', matrix.browser)) || '' }}')- echo "job_id=$job_id" >> $GITHUB_OUTPUT-- name: Create flaky tests report artifactif: steps.check-flaky-spec-report.outputs.exists == 'true'- run: cp tmp/turbo_rspec_flaky_tests.json tmp/turbo_rspec_flaky_tests-${{ matrix.build_type }}-${{ matrix.target }}-${{ steps.fetch-job-id.outputs.job_id }}.json+ run: cp tmp/turbo_rspec_flaky_tests.json tmp/turbo_rspec_flaky_tests-${{ matrix.build_type }}-${{ matrix.target }}-${{ job.check_run_id }}.json- name: Upload flaky tests reportuses: actions/upload-artifact@v6if: steps.check-flaky-spec-report.outputs.exists == 'true'with:name: flaky-test-reports-${{ matrix.build_type }}-${{ matrix.target }}- path: tmp/turbo_rspec_flaky_tests-${{ matrix.build_type }}-${{ matrix.target }}-${{ steps.fetch-job-id.outputs.job_id }}.json+ path: tmp/turbo_rspec_flaky_tests-${{ matrix.build_type }}-${{ matrix.target }}-${{ job.check_run_id }}.jsonmerge:if: github.repository == 'discourse/discourse' && github.ref == 'refs/heads/main'diff --git a/script/get_github_workflow_run_job_id.rb b/script/get_github_workflow_run_job_id.rbdeleted file mode 100644index 770c7027f3b..00000000000--- a/script/get_github_workflow_run_job_id.rb+++ /dev/null@@ -1,30 +0,0 @@-#!/usr/bin/env ruby-# frozen_string_literal: true--require "net/http"-require "json"--workflow_run_id = ARGV[0]-run_attempt = ARGV[1]-job_name = ARGV[2]--uri =- URI.parse(- "https://api.github.com/repos/discourse/discourse/actions/runs/#{workflow_run_id}/attempts/#{run_attempt}/jobs",- )--request = Net::HTTP::Get.new(uri)-request["Accept"] = "application/vnd.github+json"-request["X-Github-Api-Version"] = "2022-11-28"--response =- Net::HTTP.start(uri.host, uri.port, use_ssl: uri.is_a?(URI::HTTPS)) do |http|- http.request(request)- end--JSON.parse(response.body)["jobs"].each do |job|- if job["name"] == job_name- puts job["id"]- break- end-end