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

New (reusable) workflow to add repository items to GitHub Projects #55

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

koeaw
Copy link
Contributor

@koeaw koeaw commented Jan 29, 2024

This follows up on previous, abandoned attempts to create a workflow which allows adding of issues (and/or PRs) to GitHub Projects.

The built-in auto-add workflow by GitHub continues to only cover 1 repo for free accounts, but e.g. the APIS-RDF project is now connected to 4 or 5 repos, and it's easy to forget to manually add issues which are not covered by the built-in workflow (which means there are always issues which stay "lost" in their repos).

GitHub tokens were another blocker, I guess (?! classic PATs are extremely permissive, so I assume we wouldn't have wanted to use those) but Projects v2 have been working with fine-grained tokens for a while now.

I made this workflow reusable so other ACDH-CH projects could make use of it too if they wanted to (AFAIK there are several other GitHub projecs active within our org).

@koeaw
Copy link
Contributor Author

koeaw commented Jan 29, 2024

I purposefully didn't include the workflow's .yml extension when linking to the doc from the README because I found this confusing/misleading.

Would suggest to remove them all (and get rid of the superfluous newlines in the list), but that's a change that should go in a separate PR.

@koeaw koeaw requested a review from b1rger January 29, 2024 17:31
@koeaw
Copy link
Contributor Author

koeaw commented Jan 29, 2024

Things I'm not entirely sure about:

  • if the whitespace-formatting of those descriptions which go over one line is fine like that,
  • if the ${{ VAR }}-style variable formatting can actually be embedded in strings like that (like one would in e.g. shell scripts). I think I didn't come across any instances of strings being put in quotation marks at all in the GitHub workflow syntax docs...

add-to-project:
uses: acdh-oeaw/prosnet-workflows/.github/workflows/add-to-project.yml@RELEASE_VERSION
secrets:
ADD_TO_PROJECT_TOKEN: ${{ secrets.GH_PROJECTS_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change GH_PROJECT_TOKEN to ADD_TO_PROJECT_TOKEN, as this is the variable name we use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning behind using different names was (generally would be) to try to make variable names make a bit more sense within their respective contexts.

So for someone looking at the workflow files, ADD_TO_PROJECT_TOKEN should be recognisable as a reference to a token specific to this workflow. For someone looking at the repo's action variables and secrets, who's not been following any workflow-related developments, the name would be meaningless. They wouldn't necessarily be able to guess what exactly GH_PROJECT_* is used for either, but it could at least be a clue (hence also shared prefix for token secret + project num var).

I think it was actually the variable name in the original workflow which made me feel action secrets/vars should be a bit more helpful :P (I didn't know and couldn't guess what PAT stood for, ended up googling for it).

But I can change the name so they read the same.

@b1rger
Copy link
Contributor

b1rger commented Jan 30, 2024

tested and works!

@koeaw
Copy link
Contributor Author

koeaw commented Jan 30, 2024

tested and works!

Yay!! Very cool!

But oh nooooo, for some reason, I thought this issue only applied to classic tokens. But your tests indeed show me as the user who "added" tickets. Meh.

@koeaw koeaw force-pushed the kk/feat/new_workflow_add-to-project branch from e63bd7e to ac2e217 Compare January 31, 2024 08:49
@koeaw
Copy link
Contributor Author

koeaw commented Jan 31, 2024

Renamed the variable and included minor style + structural changes (e.g. RELEASE_VERSION appears to be required as well -> moved to correct section).

@koeaw
Copy link
Contributor Author

koeaw commented Jan 31, 2024

Btw. I think this:

But oh nooooo, for some reason, I thought this issue only applied to classic tokens. But your tests indeed show me as the user who "added" tickets. Meh.

can only be solved by using a GitHub App (which needs to be created on the org level) instead of personal tokens.

@koeaw koeaw merged commit cbc6d47 into main Jan 31, 2024
@koeaw koeaw deleted the kk/feat/new_workflow_add-to-project branch January 31, 2024 10:56
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.

2 participants