Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions .github/workflows/merge-release-to-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Merge Release to Master

on:
push:
branches:
- 'release'

jobs:
merge-release-to-master:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@github.com"

- name: Merge Release into Master
run: |
git checkout master
git merge --no-ff release -m "Merge release branch into master"
git push origin master
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

A GitHub Action that sets CDash status for your commits.

[![Release](https://img.shields.io/github/v/release/vicentebolea/cdash-status)](https://github.com/vicentebolea/cdash-status/releases)
[![Release](https://img.shields.io/github/v/release/Kitware/cdash-status)](https://github.com/Kitware/cdash-status/releases)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

## Usage

```yaml
- uses: vicentebolea/cdash-status@v1
- uses: Kitware/cdash-status@v1
with:
project: "MyProject"
```
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: CDash Status
uses: vicentebolea/cdash-status@v1
uses: Kitware/cdash-status@v1
with:
project: "MyProject"
```
Expand All @@ -49,10 +49,17 @@ jobs:
1. Fork the repository
2. Create a feature branch: `git checkout -b my-new-feature`
3. Commit your changes using [Conventional Commits](https://www.conventionalcommits.org/):
- `feat: add new feature`
- `fix: fix a bug`
- `docs: update documentation`
- `chore: maintenance tasks`
- `feat`: add a new feature (MINOR release)
- `fix`: fix a bug (PATCH release)
- `docs`: documentation changes only
- `style`: changes that don't affect code meaning (formatting, whitespace)
- `refactor`: code change that neither fixes a bug nor adds a feature
- `perf`: performance improvements
- `test`: adding or updating tests
- `build`: changes to build system or dependencies
- `ci`: changes to CI configuration
- `chore`: other changes that don't modify src or test files
- Adding `BREAKING CHANGE:` to the footer triggers a MAJOR release
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request

Expand All @@ -63,11 +70,11 @@ Releases are automatically created when commits are merged to the `release` bran

- `fix:` commits trigger a PATCH release (1.0.x)
- `feat:` commits trigger a MINOR release (1.x.0)
- `feat!:` or `fix!:` or any commit with `BREAKING CHANGE:` in the footer triggers a MAJOR release (x.0.0)
- Any commit with `BREAKING CHANGE:` in the footer triggers a MAJOR release (x.0.0)

## Authors

- Vicente Bolea @ Kitware
- Vicente Bolea <vicente.bolea@kitware.com>

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/vicentebolea/cdash-status.git"
"url": "https://github.com/kitware/cdash-status.git"
},
"keywords": [
"cdash",
Expand Down
50 changes: 37 additions & 13 deletions post-cdash-status
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,27 @@ require_env_var "GITHUB_TOKEN"

#==============================================================================

statuses=$(curl -q -s \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${API_BASE}/commits/${COMMIT_SHA}/statuses" |\
jq -r '[.[].context] | @json')
readonly status_response=$(
curl -q -s \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${API_BASE}/commits/${COMMIT_SHA}/statuses")

# The API returns an empty array if no statuses were found
# This can happen if the COMMIT_SHA doesn't point to the head of the branch/PR
if [ "true" == $(jq -r '. == []' <<<$status_response) ]; then
echo "No statuses found for '${API_BASE}/commits/${COMMIT_SHA}'"
exit 1
fi

readonly statuses=$(jq -r '[.[].context] | @json' <<< $status_response)
if [ -z "$statuses" ]; then
echo "Failed to parse statuses for '${API_BASE}/commits/${COMMIT_SHA}'"
echo -e "Request returned:\n$status_response"
exit 2
fi

post_body="$(cat<<EOF
{
Expand All @@ -47,13 +62,22 @@ EOF

post_url="${API_BASE}/statuses/${COMMIT_SHA}"

if jq -re "all(. != \"${GITHUB_STATUS_NAME}\")" <<<"${statuses}"; then
if [ "true" == $(jq -re "all(. != \"${GITHUB_STATUS_NAME}\")" <<<"${statuses}") ]; then
echo "Need to post a status for context ${GITHUB_STATUS_NAME}"

curl -X POST -q -s \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d "${post_body}" "${post_url}"
readonly response=$(
curl -X POST -q -s \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d "${post_body}" "${post_url}")

if [ "false" == $(jq -r 'has("creator")') <<<"$response" ]; then
echo "Failed to create status for '${API_BASE}/commits/${COMMIT_SHA}'"
echo -e "Request returned:\n$response"
exit 3
fi
else
echo "No status updates needed."
fi
Loading