Skip to content
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

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

stoyanK7
Copy link
Contributor

Resolves #12570

Final result / Proof

Actions job

Milestones

Test milestone was closed and 10.7.0 was created.
image

Release

The asset was uploaded.
image

Issues

Issues were created.

eclipse-cs

sonar-checkstyle

@@ -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" \
Copy link
Contributor Author

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" \
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 \
Copy link
Contributor Author

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
Copy link
Contributor Author

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 }}
Copy link
Contributor Author

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:

  1. Click on profile picture on top right of the screen
  2. Click Settings
  3. On the left menu, go all the way down to <> Developer Settings
  4. Click Personal access tokens
  5. Click Fine-grained tokens
  6. Click Generate new token
  7. Choose name, description, repositories, etc..
    image
  8. Click Repository permissions and find Issues. Choose Read and Write access
    image
  9. Generate token and copy
  10. Go to checkstyle repository and click Settings
  11. On the left menu, under Security, click Secrets and variables and then Actions
  12. Click New repository secret and add it with the name of ISSUES_WRITE_TOKEN
    image
  13. Add token and you should be good to go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is problem with this, as I donot see repositories of checkstyle organization, I see only personal repos

image

Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

@romani romani left a 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

@romani romani merged commit 309d5a0 into checkstyle:master Jan 31, 2023
@stoyanK7 stoyanK7 deleted the issue/12570 branch January 31, 2023 13:37
@romani
Copy link
Member

romani commented Jan 31, 2023

done at ff239e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

action 'R: Close/Create Milestone' is not working
2 participants