-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #12570: action 'R: Close/Create Milestone' is not working #12683
Conversation
@@ -28,8 +28,8 @@ RELEASE_ID=$(curl -s -X GET \ | |||
|
|||
|
|||
curl -i -H "Authorization: token $GITHUB_TOKEN" \ | |||
-H "Content-Type: application/zip" \ | |||
--data-binary @"target/checkout/target/checkstyle-$TARGET_VERSION-all.jar" \ | |||
-H "Content-Type: application/java-archive" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to MDN, the proper type should be application/java-archive
if we want to be exact.
-H "Content-Type: application/zip" \ | ||
--data-binary @"target/checkout/target/checkstyle-$TARGET_VERSION-all.jar" \ | ||
-H "Content-Type: application/java-archive" \ | ||
--data-binary @"target/checkstyle-$TARGET_VERSION-all.jar" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .jar
file is located in target/
folder, not target/checkout/target/
.
@@ -24,6 +25,11 @@ jobs: | |||
steps: | |||
- name: Checkout the latest code | |||
uses: actions/checkout@v3 | |||
with: | |||
fetch-depth: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch-depth
is needed so we can pull the tags as well as stated in this answer.
This is why this error popped up in the original issue:
error: pathspec 'checkstyle-10.6.0' did not match any file(s) known to git
fetch-depth: 0 | ||
- name: Download xmlstarlet and ncal | ||
run: | | ||
sudo apt-get install xmlstarlet ncal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cal
and xmlstarlet
were missing as shown here.
@@ -7,12 +7,12 @@ source ./.ci/util.sh | |||
checkForVariable "GITHUB_TOKEN" | |||
|
|||
echo "Close previous milestone at github" | |||
MILESTONE_ID=$(curl -s \ | |||
MILESTONE_NUMBER=$(curl -s \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MILESTONE_NUMBER
is more-accurate since id
is also present in the response from GitHub and it represents something else.
@@ -12,6 +12,7 @@ on: | |||
|
|||
permissions: | |||
contents: write | |||
issues: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason for
issues: write
is insuffcient permissions as shown in this failing job.
According to the docs, we need to grant write
access to issues
to call PATCH /repos/{owner}/{repo}/milestones/{milestone_number}
.
@@ -38,6 +44,6 @@ jobs: | |||
|
|||
- name: Creation of issue in other Repositories | |||
env: | |||
GITHUB_TOKEN: ${{ github.token }} | |||
GITHUB_TOKEN: ${{ secrets.ISSUES_WRITE_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are dealing with multiple repositories github.token
will not be enough.
You need to create a personal access token.
I followed these steps and called it ISSUES_WRITE_TOKEN
:
- Click on profile picture on top right of the screen
- Click
Settings
- On the left menu, go all the way down to
<> Developer Settings
- Click
Personal access tokens
- Click
Fine-grained tokens
- Click
Generate new token
- Choose name, description, repositories, etc..
- Click
Repository permissions
and findIssues
. ChooseRead and Write
access
- Generate token and copy
- Go to
checkstyle
repository and clickSettings
- On the left menu, under
Security
, clickSecrets and variables
and thenActions
- Click
New repository secret
and add it with the name ofISSUES_WRITE_TOKEN
- Add token and you should be good to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move this activities in other repositories to other workflow, or simply use PAT (that already exists in our secrets)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will keep this in mind in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to merge I will use PAT secret in action for creation of issues other repos
done at ff239e0 |
Resolves #12570
Final result / Proof
Actions job
Milestones
Test milestone
was closed and10.7.0
was created.Release
The asset was uploaded.
Issues
Issues were created.
eclipse-cs
sonar-checkstyle