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

Actions (#872) #939

Merged
merged 1 commit into from
Dec 3, 2020
Merged

Actions (#872) #939

merged 1 commit into from
Dec 3, 2020

Conversation

lexor
Copy link
Contributor

@lexor lexor commented Nov 25, 2020

  • Artifacts
  • Secrets
  • Self-hosted runners
  • Workflows
  • Workflow jobs
  • Workflow runs

Documentation: https://developer.github.com/v3/actions/

@lexor lexor force-pushed the lexor/github-actions branch 3 times, most recently from 0612c92 to c81fadb Compare November 26, 2020 01:14
@acrobat
Copy link
Collaborator

acrobat commented Nov 26, 2020

Thanks for working on this @lexor! Let me know when it's ready for review 🚢

@fodinabor
Copy link
Contributor

fodinabor commented Nov 27, 2020

What's missing from the developer.github.com documentation is e.g. dispatching:
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event

I've been successful with:

    /**
     * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event
     *
     * @param string $username
     * @param string $repository
     * @param string $workflowId
     * @param string $ref
     * @param array  $inputs
     *
     * @return array|string
     */
    public function dispatches(string $username, string $repository, string $workflowId, string $ref, array $inputs = [])
    {
        $parameters = array('ref' => $ref, 'inputs' => $inputs);
        return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.rawurlencode($workflowId).'/dispatches', $parameters);
    }

Another note: workflowId is in most cases allowed to contain the filename of the workflow, so string should be preferred over int

@lexor
Copy link
Contributor Author

lexor commented Nov 28, 2020

What's missing from the developer.github.com documentation is e.g. dispatching:
docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event

Thanks for sharing the dispatches function, but this pull request based on this documentation. After this pull request I can work on this documentation.

I'm not add organization endpoints (self-hosted runners) because marked on documentation. Organization endpoints currently in public beta and can be change.

Another note: workflowId is in most cases allowed to contain the filename of the workflow, so string should be preferred over int

I think it can be changed from workflowId to workflow.

@lexor lexor force-pushed the lexor/github-actions branch 2 times, most recently from 16e1d6d to 4f25590 Compare November 28, 2020 06:21
@lexor lexor changed the title [WIP] Actions (#872) Actions (#872) Nov 28, 2020
@lexor lexor marked this pull request as ready for review November 28, 2020 10:18
@lexor
Copy link
Contributor Author

lexor commented Nov 28, 2020

Hey @acrobat. This pull request awaiting review.

@fodinabor
Copy link
Contributor

For Get a workflow for example the docs write:

Gets a specific workflow. You can also replace :workflow_id with :workflow_file_name. For example, you could use main.yml.

So, yeah I guess a string parameter named just workflow would make sense here.

@acrobat
Copy link
Collaborator

acrobat commented Nov 29, 2020

@fodinabor the repo dispatch api endpoint is already added in #931

@lexor A general remark before I do a full review, can you update the doc links to directly link to the new documentation? Example: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions

@lexor
Copy link
Contributor Author

lexor commented Nov 29, 2020

@lexor A general remark before I do a full review, can you update the doc links to directly link to the new documentation? Example: docs.github.com/en/free-pro-team@latest/rest/reference/actions

Done, I updated 👍

Copy link
Collaborator

@acrobat acrobat left a comment

Choose a reason for hiding this comment

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

This comment is also applicable to all occurences of non-query parameters

Can you replace the non url parameters with a array $params/parameters , so our code isn't fixed on a certain set of parameters of github decides to add new options.

Can you also add a docs entry for the added endpoints? The rest of PR looks good 👌

lib/Github/Api/Organization/Actions/Secrets.php Outdated Show resolved Hide resolved
lib/Github/Api/Repository/Actions/Artifacts.php Outdated Show resolved Hide resolved
lib/Github/Api/Repository/Actions/WorkflowJobs.php Outdated Show resolved Hide resolved
lib/Github/Api/Repository/Actions/WorkflowRuns.php Outdated Show resolved Hide resolved
feat(actions): added self-hosted runners

Signed-off-by: Emre DEĞER <ben@emre.dev>

repo: added actions

feat(actions): added self-hosted runners

Signed-off-by: Emre DEĞER <ben@emre.dev>

repo: added actions

refactored

fix(actions: reformated self-hosted runners

repo: added actions

refactored

fix(actions: reformated self-hosted runners

feat(actions): added repo's secrets

Signed-off-by: Emre DEĞER <ben@emre.dev>

feat(actions): added organization's secrets

Signed-off-by: Emre DEĞER <ben@emre.dev>

feat(actions): formated

Signed-off-by: Emre DEĞER <ben@emre.dev>

docs(actions): updated php doc blocks

updated `@link` for new docs

Signed-off-by: Emre DEĞER <ben@emre.dev>

feat(actions): updated for requested changes

Signed-off-by: Emre DEĞER <ben@emre.dev>

feat(actions): added docs

Signed-off-by: Emre DEĞER <ben@emre.dev>

feat(actions): updated download example cases

Signed-off-by: Emre DEĞER <ben@emre.dev>

fix(actions): removed todos

Signed-off-by: Emre DEĞER <ben@emre.dev>
@lexor
Copy link
Contributor Author

lexor commented Nov 30, 2020

Can you replace the non url parameters with a array $params/parameters , so our code isn't fixed on a certain set of parameters of github decides to add new options.

Sure, replaced. Now non url parameters moved on array $parameters.

Can you also add a docs entry for the added endpoints? The rest of PR looks good 👌

I updated functions and test cases. Also added docs for added endpoints.

@lexor lexor requested a review from acrobat December 1, 2020 17:37
@acrobat acrobat merged commit 0889fc2 into KnpLabs:2.x Dec 3, 2020
@acrobat
Copy link
Collaborator

acrobat commented Dec 3, 2020

Thanks @lexor! And congrats on your first contribution! 🎉

@lexor lexor deleted the lexor/github-actions branch December 3, 2020 11:31
@acrobat acrobat mentioned this pull request Dec 3, 2020
6 tasks
@acrobat acrobat linked an issue Dec 3, 2020 that may be closed by this pull request
6 tasks
acrobat added a commit that referenced this pull request Mar 6, 2021
This PR was merged into the 3.0.x-dev branch.

Discussion
----------

Adds the workflow dispatch proposed in #939.
This is different from the repository dispatch, as here it is clear what arguments to use, so that this is much more convenient to use.

Also update docs link.

Commits
-------

61366b2 Add workflow dispatch and allow workflow names.
@dereuromark
Copy link
Contributor

What I am missing is the enable of a specific workflow
See https://docs.github.com/en/rest/reference/actions#enable-a-workflow

@lexor
Copy link
Contributor Author

lexor commented Apr 14, 2021

What I am missing is the enable of a specific workflow
See docs.github.com/en/rest/reference/actions#enable-a-workflow

Looks like endpoint was added or I missed it. I can create pull request for enable/disable endpoints.

@dereuromark
Copy link
Contributor

dereuromark commented Apr 14, 2021

Yeah, might be new.
But I also struggle finding the right syntax.
The docs say this should work:

$url = 'repos/' . rawurlencode($organization) . '/' . rawurlencode($repository) . '/actions/workflows/' . (string)$id . '/enable';

$this->post($url);

But it returns Not Found
I made sure to use a token that has permissions for "Workflows".

The dispatches() example above works, which makes this even weirder.

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.

Github actions api
4 participants