forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify_for_autoupgrade_pr_label.yml
More file actions
79 lines (67 loc) · 3.95 KB
/
notify_for_autoupgrade_pr_label.yml
File metadata and controls
79 lines (67 loc) · 3.95 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
# This workflow allows you to add a comment to the pull request if the label "Needs autoupgrade PR" is present and there are at least 2 approves
name: Notify for 'Needs autoupgrade PR' label
on:
workflow_run:
workflows: [ Verify 'Needs autoupgrade PR' label and approvals ]
types:
- completed
jobs:
add_comment:
name: Add comment
runs-on: ubuntu-latest
steps:
- id: download_artifact
name: Download artifact
uses: actions/github-script@v6
with:
script: |
const workflowRun = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId,
});
const pullRequest = workflowRun.data.pull_requests?.[0];
if (!pullRequest) {
throw new Error("No pull request found for the triggering workflow run.");
}
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "approval_count"
})[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/approval_count.zip`, Buffer.from(download.data));
return {
number: pullRequest.number,
author: pullRequest.user.login,
};
result-encoding: json
- name: Unzip artifact
run: |
unzip sql_diff.zip
echo "approvals=$(cat ./approvals)" >> $GITHUB_ENV
echo "label_present=$(cat ./label)" >> $GITHUB_ENV
- name: Check diff for label
if: ${{ env.approvals >= 2 && env.label_present == '1' }}
run: |
PR_NUMBER=${{ steps.download_artifact.outputs.number }}
PR_CREATOR=${{ steps.download_artifact.outputs.author }}
COMMENT="Hello @$PR_CREATOR,<br/>
Please note that the “Needs autoupgrade PR” label has been automatically added to your Pull Request. This means that the changes made in your PR must also be reported in the Autoupgrade module, responsible for running the update process of PrestaShop stores.<br/>
When there's a modification to the \`db-structure.sql\` file or if a Doctrine entity has been modified, added, or deleted, it impacts the database structure. Modifying the list of hooks and feature flags has consequences on the update process as well. These changes can affect how the application interacts with the database and how update procedures are handled. It's important to consider these aspects when contributing to ensure a smooth update experience for users.<br/>
That's why this contribution should be backported, with another corresponding PR, on the Autoupgrade module's GitHub repository which is available here: [Autoupgrade Repository](https://github.com/PrestaShop/autoupgrade)
Contribution to the Autoupgrade module documentation: [Documentation Link](https://devdocs.prestashop-project.org/9/contribute/contribution-guidelines/upgrade-module/)<br/>
Don't forget to add a comment in this current thread with the link to this PR once it has been created.<br/>
If you are sure that your Pull Request doesn’t require additional actions, ping [committers](https://www.prestashop-project.org/project-organization/people-and-roles/#committers) and it will be checked.<br/>
Thank you."
gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments \
-f body="$COMMENT"