|
1 |
| -name: 'Handle Specific Code of Conduct Scenarios' |
2 |
| -description: 'Handles scenarios for missing Code of Conduct or outdated Contributor Covenant version.' |
3 |
| -inputs: |
4 |
| - USER_GITHUB_TOKEN: |
5 |
| - description: 'User GitHub Token' |
6 |
| - required: true |
7 |
| - EVENT_ACTION: |
8 |
| - description: 'Event action that triggered the workflow' |
9 |
| - required: true |
10 |
| - |
11 |
| -runs: |
12 |
| - using: 'composite' |
13 |
| - steps: |
14 |
| - - name: Checkout repository |
15 |
| - uses: actions/checkout@v4 |
16 |
| - with: |
17 |
| - persist-credentials: false |
18 |
| - fetch-depth: 0 |
19 |
| - |
20 |
| - - name: Configure Git user |
21 |
| - shell: bash |
22 |
| - run: | |
23 |
| - git config --global user.name 'BigBOSS-SOM' |
24 |
| - git config --global user.email '[email protected]' |
25 |
| -
|
26 |
| - - name: Authenticate for git fetch |
27 |
| - shell: bash |
28 |
| - run: | |
29 |
| - git remote set-url origin https://BigBOSS-SOM:${{ inputs.USER_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git |
30 |
| -
|
31 |
| - - name: Fetch all branches |
32 |
| - shell: bash |
33 |
| - run: git fetch --all |
34 |
| - |
35 |
| - - name: Create or switch to branch |
36 |
| - shell: bash |
37 |
| - run: | |
38 |
| - if [ "${{ inputs.EVENT_ACTION }}" == "no_code_of_conduct" ]; then |
39 |
| - branch="add-code-of-conduct" |
40 |
| - elif [ "${{ inputs.EVENT_ACTION }}" == "handle_contributor_covenant_1_4" ]; then |
41 |
| - branch="update-code-of-conduct" |
42 |
| - fi |
43 |
| - if git show-ref --verify --quiet refs/heads/$branch; then |
44 |
| - git checkout $branch |
45 |
| - else |
46 |
| - git checkout -b $branch |
47 |
| - fi |
48 |
| -
|
49 |
| - - name: Add or Update CODE_OF_CONDUCT.md |
50 |
| - shell: bash |
51 |
| - run: | |
52 |
| - cp $GITHUB_ACTION_PATH/.github/templates/CODE_OF_CONDUCT.md . |
53 |
| - git add CODE_OF_CONDUCT.md |
54 |
| - if [ "${{ inputs.EVENT_ACTION }}" == "no_code_of_conduct" ]; then |
55 |
| - git commit -m "Add CODE_OF_CONDUCT.md" || echo "No changes to commit" |
56 |
| - elif [ "${{ inputs.EVENT_ACTION }}" == "handle_contributor_covenant_1_4" ]; then |
57 |
| - git commit -m "Update CODE_OF_CONDUCT.md to Contributor Covenant 2.1" || echo "No changes to commit" |
58 |
| - fi |
59 |
| -
|
60 |
| - - name: Push changes |
61 |
| - shell: bash |
62 |
| - env: |
63 |
| - USER_GITHUB_TOKEN: ${{ inputs.USER_GITHUB_TOKEN }} |
64 |
| - run: | |
65 |
| - git remote set-url origin https://BigBOSS-SOM:${{ inputs.USER_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git |
66 |
| - if [ "${{ inputs.EVENT_ACTION }}" == "no_code_of_conduct" ]; then |
67 |
| - git push -u origin add-code-of-conduct |
68 |
| - elif [ "${{ inputs.EVENT_ACTION }}" == "handle_contributor_covenant_1_4" ]; then |
69 |
| - git push -u origin update-code-of-conduct |
70 |
| - fi |
71 |
| -
|
72 |
| - - name: Set Pull Request Branch |
| 1 | + - name: Set Pull Request Environment Variables |
73 | 2 | shell: bash
|
74 | 3 | run: |
|
75 | 4 | if [ "${{ inputs.EVENT_ACTION }}" == "no_code_of_conduct" ]; then
|
76 | 5 | echo "PULL_REQUEST_FROM_BRANCH=add-code-of-conduct" >> $GITHUB_ENV
|
| 6 | + echo "PULL_REQUEST_TITLE=Add Code of Conduct" >> $GITHUB_ENV |
| 7 | + echo "PULL_REQUEST_BODY=This pull request adds a Code of Conduct to the repository." >> $GITHUB_ENV |
77 | 8 | elif [ "${{ inputs.EVENT_ACTION }}" == "handle_contributor_covenant_1_4" ]; then
|
78 | 9 | echo "PULL_REQUEST_FROM_BRANCH=update-code-of-conduct" >> $GITHUB_ENV
|
| 10 | + echo "PULL_REQUEST_TITLE=Update Code of Conduct to Contributor Covenant 2.1" >> $GITHUB_ENV |
| 11 | + echo "PULL_REQUEST_BODY=We have detected that your current Code of Conduct is based on Contributor Covenant version 1.4. It would be great to update it to the latest version 2.1 to ensure it includes the most recent improvements and guidelines." >> $GITHUB_ENV |
79 | 12 | fi
|
80 | 13 |
|
81 | 14 | - name: Create Pull Request
|
82 | 15 | uses: vsoch/pull-request-action@master
|
83 | 16 | env:
|
84 | 17 | GITHUB_TOKEN: ${{ inputs.USER_GITHUB_TOKEN }}
|
85 |
| - with: |
86 |
| - head: ${{ env.PULL_REQUEST_FROM_BRANCH }} |
87 |
| - base: "main" |
88 |
| - title: ${{ inputs.EVENT_ACTION == 'no_code_of_conduct' && 'Add Code of Conduct' || 'Update Code of Conduct to Contributor Covenant 2.1' }} |
89 |
| - body: ${{ inputs.EVENT_ACTION == 'no_code_of_conduct' && 'This pull request adds a Code of Conduct to the repository.' || 'We have detected that your current Code of Conduct is based on Contributor Covenant version 1.4. It would be great to update it to the latest version 2.1 to ensure it includes the most recent improvements and guidelines.' }} |
90 |
| - labels: "code of conduct, documentation" |
| 18 | + PULL_REQUEST_BRANCH: "main" |
| 19 | + PULL_REQUEST_FROM_BRANCH: ${{ env.PULL_REQUEST_FROM_BRANCH }} |
| 20 | + PULL_REQUEST_TITLE: ${{ env.PULL_REQUEST_TITLE }} |
| 21 | + PULL_REQUEST_BODY: ${{ env.PULL_REQUEST_BODY }} |
| 22 | + PULL_REQUEST_LABELS: "code of conduct, documentation" |
0 commit comments