Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This template is taken from the cruft example code, for further information please see:
# https://cruft.github.io/cruft/#automating-updates-with-github-actions
name: Automatic Update from package template
permissions:
contents: write
pull-requests: write

on:
# Allow manual runs through the web UI
Expand All @@ -19,14 +16,17 @@ on:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.11"
python-version: "3.14"

- name: Install Cruft
run: python -m pip install git+https://github.com/Cadair/cruft@patch-p1
Expand Down Expand Up @@ -93,3 +93,70 @@ jobs:
If this pull request has been opened as a draft there are conflicts which need fixing.

**To run the CI on this pull request you will need to close it and reopen it.**

report-fail:
if: failure()
needs: [update]
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Open an issue if workflow fails
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
# This script is adapted from https://github.com/scientific-python/issue-from-pytest-log-action
# Under MIT license (c) Scientific Python Developers
script: |
const fs = require('fs');

// Edit these if needed for your repo
const variables = {
owner: context.repo.owner,
name: context.repo.repo,
label: "Infrastructure",
creator: "app/github-actions",
title: "SunPy Package Template auto-update failed."
};

const logs = 'The package update workflow 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${logs}`;

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 {
search(query: "${query_string}", type:ISSUE, first: 1) {
edges {
node {
... on Issue {
body
id
number
}
}
}
}
}`;

const result = await github.graphql(query);

// If no issue is open, create a new issue,
// else update the body of the existing issue.
if (result.search.edges.length === 0) {
github.rest.issues.create({
owner: variables.owner,
repo: variables.n ame,
body: issue_body,
title: variables.title,
labels: [variables.label],
});
} else {
github.rest.issues.update({
owner: variables.owner,
repo: variables.name,
issue_number: result.search.edges[0].node.number,
body: issue_body
});
}