diff --git a/.github/workflows/merge-release-to-master.yml b/.github/workflows/merge-release-to-master.yml new file mode 100644 index 0000000..e5de9d0 --- /dev/null +++ b/.github/workflows/merge-release-to-master.yml @@ -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 diff --git a/README.md b/README.md index b8e2bfd..4ecd484 100644 --- a/README.md +++ b/README.md @@ -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" ``` @@ -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" ``` @@ -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 @@ -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 ## License diff --git a/package.json b/package.json index 33afc58..e4c11f9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/post-cdash-status b/post-cdash-status index 85ae473..d934700 100755 --- a/post-cdash-status +++ b/post-cdash-status @@ -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<