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

Bump actions/github-script from 6 to 7 #114

Merged
merged 2 commits into from
Feb 3, 2025
Merged
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
46 changes: 25 additions & 21 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,32 @@ jobs:
shopt -s globstar
python .github/workflows/format-report.py logs/**/*-log sphinx-log.txt
- name: Report failures
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ github.token }}
script: |
const fs = require('fs');
const sphinx_logs = fs.readFileSync('sphinx-logs.txt', 'utf8');
const title = "⚠️ Nightly upstream-dev CI failed ⚠️"
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
const issue_body = `[Workflow Run URL](${workflow_url})\n${sphinx_logs}`
const fs = require("fs");
const sphinx_logs = fs.readFileSync("sphinx-logs.txt", "utf8");
const title = "⚠️ Nightly upstream-dev CI failed ⚠️";
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const issue_body = `[Workflow Run URL](${workflow_url})\n${sphinx_logs}`;

const variables = {
owner: context.repo.owner,
name: context.repo.repo,
label: "CI"
creator: "app/github-actions",
title: title,
};

const query_string = `repo:${variables.owner}/${variables.name} author:${variables.creator} label:${variables:label} is:open in:title ${variables.title}`;

// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
repository(owner: $owner, name: $name) {
issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) {
edges {
node {
const query = `query {
search(query: "${query_string}", type:ISSUE, first: 1) {
edges {
node {
... on Issue {
body
id
number
Expand All @@ -140,13 +150,7 @@ jobs:
}
}`;

const variables = {
owner: context.repo.owner,
name: context.repo.repo,
label: 'CI',
creator: "github-actions[bot]"
}
const result = await github.graphql(query, variables)
const result = await github.graphql(query);

// If no issue is open, create a new issue,
// else update the body of the existing issue.
Expand All @@ -157,12 +161,12 @@ jobs:
body: issue_body,
title: title,
labels: [variables.label]
})
});
} else {
github.rest.issues.update({
owner: variables.owner,
repo: variables.name,
issue_number: result.repository.issues.edges[0].node.number,
body: issue_body
})
});
}
Loading