Skip to content

Commit

Permalink
79 Associate GitHub actions to PR tags (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaCalderon authored Apr 18, 2023
1 parent 4ba98c2 commit 6db32b0
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Greetings

on: [ pull_request, issues ]
on: [pull_request, issues]

jobs:
greeting:
Expand All @@ -10,5 +10,5 @@ jobs:
continue-on-error: true
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Thank you for collaborating with the project by giving us feedback!!"
pr-message: "Thank you for collaborating with the project to help us to improve!! We hope the plugin is useful to you. Cheers!"
issue-message: "Thank you for collaborating with the project by giving us feedback!"
pr-message: "Thank you for collaborating with the project to help us to improve! We hope the plugin is useful to you. Cheers!"
20 changes: 16 additions & 4 deletions .github/workflows/maven-central-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@ name: Java CI with Maven (Push)

on:
push:
branches: [ main ]
branches: [main]

jobs:
build:

check-pr-labels:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
labels: ${{ steps.get-pr.outputs.pr_labels }}
steps:
- name: Get Pull Request information
uses: 8BitJonny/[email protected]
id: get-pr

build:
runs-on: ubuntu-latest
needs: [check-pr-labels]
if: contains(needs.check-pr-labels.outputs.labels, 'release')
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -17,8 +29,8 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
java-version: "11"
distribution: "adopt"
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/maven-pr-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Pull Request Approved

on:
pull_request_review:
types: [submitted]

concurrency: pr-${{ github.event.pull_request.id }}

jobs:
check-labels:
runs-on: ubuntu-latest
if: github.event.pull_request.mergeable == true && github.event.review.state == 'approved'
steps:
- name: Warn about missing labels
if: ${{ !contains(github.event.pull_request.labels.*.name, 'release') && !contains(github.event.pull_request.labels.*.name, 'documentation') }}
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: "This pull request hasn't been labeled as `release` nor `documentation`. Please ensure this is intentional before merging."
comment_tag: label-warn
23 changes: 19 additions & 4 deletions .github/workflows/maven-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ name: Java CI with Maven (PR)

on:
pull_request:
types: [ opened, synchronize, ready_for_review, review_requested ]
types: [ opened, synchronize, ready_for_review, review_requested, labeled ]

concurrency: pr-${{ github.event.pull_request.id }}

jobs:
check-version:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'release')
steps:
- uses: actions/checkout@v3
- name: Check if version is updated
Expand All @@ -21,7 +24,7 @@ jobs:
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: Project version has not been updated in pom.xml. Please, update your version using https://semver.org specifications
message: Project version has not been updated in pom.xml. Please, update your version using https://semver.org specifications.
- name: Exit if fails
if: steps.actions_project_version_check.outcome != 'success'
uses: cutenode/action-always-fail@v1
Expand All @@ -36,7 +39,19 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
java-version: "11"
distribution: "adopt"
- name: Build with Maven
run: mvn -B package --file pom.xml

check-labels:
runs-on: ubuntu-latest
if: github.event.pull_request.mergeable == true
steps:
- name: Warn about missing labels
if: ${{ !contains(github.event.pull_request.labels.*.name, 'release') && !contains(github.event.pull_request.labels.*.name, 'documentation') }}
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: "This pull request hasn't been labeled as `release` nor `documentation`. Please ensure this is intentional before merging."
comment_tag: label-warn
58 changes: 58 additions & 0 deletions .github/workflows/update-wiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Sync Docs (Merge)

on:
push:
branches: [main]

jobs:
check-pr-labels:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
labels: ${{ steps.get-pr.outputs.pr_labels }}
steps:
- name: Get Pull Request information
uses: 8BitJonny/[email protected]
id: get-pr

update-wiki:
runs-on: ubuntu-latest
needs: [check-pr-labels]
if: contains(needs.check-pr-labels.outputs.labels, 'documentation')
steps:
- name: Setup variables
run: |
echo "REPO_DEST=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}').wiki" >> $GITHUB_ENV
shell: bash
- name: Checkout SCC Multiapi Converter Repository
run: git clone https://github.com/sngular/scc-multiapi-converter.git scc-multiapi-converter
- name: Checkout SCC Multiapi Converter Wiki Repository
run: git clone https://github.com/sngular/scc-multiapi-converter.wiki.git wiki
- name: Copy docs and consolidate links
run: |
cp -rf scc-multiapi-converter/docs/* wiki/
cd wiki
grep -lr "(.*\.md)" *|xargs -r sed -i 's/\.md//g'
echo ">"
git diff-index --quiet HEAD & git status -s
echo "<"
git status
echo ">"
git diff-index --quiet HEAD & git status -s
echo "<"
echo "TO_BE_CANCELLED=$(if [[ $(git diff-index --quiet HEAD & git status -s) ]]; then echo "false"; else echo "true"; fi)" >> $GITHUB_ENV
echo "$TO_BE_CANCELLED"
- name: Setup git user
if: ${{ env.TO_BE_CANCELLED == 'false' }}
run: |
git config --global user.name ${{ github.actor }}
- name: Sync Wiki
if: ${{ env.TO_BE_CANCELLED == 'false' }}
run: |
cd wiki
git status
git add .
git commit -m "scc-multiapi-converter documentation | GitHub Actions $GITHUB_WORKFLOW $GITHUB_RUN_NUMBER"
git remote add origin-wiki "https://${{secrets.GITBOT_TOKEN}}@github.com/sngular/scc-multiapi-converter.wiki.git"
git push origin-wiki main
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ interactions with the project.
3. Increase the version numbers in any examples files and the README.md to the
new version that this Pull Request would represent. The versioning scheme we
use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other
4. If your Pull Request corresponds to a new release, label it as `release`. If
it updates the documentation, label it as `documentation`. You can add both
labels simultaneously if that is the case.
5. You may squash and merge the Pull Request in once you have the sign-off of two other
developers, or if you do not have permission to do that, you may request the
second reviewer to merge it for you.

Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

# SCC Verifier MultiApi Converter

## ❗❗We have moved
We have migrated to a new domain: https://github.com/sngular/scc-multiapi-converter.
This is the only change, you can find it and keep it using it as usual from there.



## 📜 Summary

SCC Verifier MultiApi Converter allows us to use Spring Cloud Contract to generate contracts from an OpenApi yaml document or an AsyncApi document. This plugin will detect automatically what contract needs to be generated
Expand Down

0 comments on commit 6db32b0

Please sign in to comment.