-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (68 loc) · 2.69 KB
/
Copy path3-step.yml
File metadata and controls
79 lines (68 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Step 3
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
permissions:
contents: read
actions: write
issues: write
pull-requests: write
env:
STEP_4_FILE: ".github/steps/4-step.md"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
find_exercise:
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
step4_merge_guidance:
name: Post Step 4 (merge/conflicts) guidance
needs: [find_exercise]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
env:
ISSUE_REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect PR mergeability
id: prinfo
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const number = context.payload.pull_request.number;
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number });
core.setOutput('mergeable_state', pr.mergeable_state || 'unknown');
- name: Build status line
id: status
run: |
state='${{ steps.prinfo.outputs.mergeable_state }}'
if [ "$state" = "clean" ] || [ "$state" = "unstable" ] || [ "$state" = "blocked" ]; then
echo "line=✅ Pas de conflit bloquant détecté, tu peux **fusionner** ta PR" >> $GITHUB_OUTPUT
elif [ "$state" = "dirty" ]; then
echo "line=⚠️ Conflits détectés, suis les étapes ci-dessous pour les résoudre" >> $GITHUB_OUTPUT
else
echo "line=ℹ️ État de fusion inconnu pour le moment, suis le guide ci-dessous si GitHub indique des conflits" >> $GITHUB_OUTPUT
fi
- name: Find existing Step 4 comment
id: find
uses: peter-evans/find-comment@v3
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
comment-author: github-actions[bot]
body-includes: "## Étape 4, résoudre les conflits et fusionner"
- name: Create or update Step 4 comment
uses: GrantBirki/comment@v2.1.1
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: ${{ env.STEP_4_FILE }}
edit-mode: ${{ steps.find.outputs.comment-id && 'replace' || 'append' }}
comment-id: ${{ steps.find.outputs.comment-id }}
vars: |
status_line: ${{ steps.status.outputs.line }}