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

Add workflow file through CLI #64

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion doc/user-guide/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

You can use GitHub Actions to deploy your project on each push.

## Set Github secret

First, you need to get your [API key](../quickstart/apikey.md). Once you have the API
key, you need to store it as a GitHub secret in your repository:

Expand All @@ -10,6 +12,8 @@ key, you need to store it as a GitHub secret in your repository:
![](../static/github/set-secret.png)


## Initialize project

Then, install the CLI:

```sh
Expand All @@ -31,6 +35,9 @@ ploomber-cloud init

`init` will create a `ploomber-cloud.json` file. For more information on the `init` command, see [](../user-guide/cli.md)

(monitor)=
## Configure and monitor Github actions

Now, configure GitHub actions by adding [this YAML file](https://github.com/edublancas/cloud-template/blob/main/.github/workflows/ploomber-cloud.yaml) in `.github/workflows/ploomber-cloud.yaml`

Finally, commit and push the new files:
Expand Down Expand Up @@ -69,4 +76,28 @@ Without `--watch`, the logs will look like this:

![](../static/github/logs.png)

A complete sample project is [available here.](https://github.com/edublancas/cloud-template)
A complete sample project is [available here.](https://github.com/edublancas/cloud-template)

## Configure action through CLI

If your project is already hosted on Github, running `ploomber-cloud init` inside your repository folder will initialize
the project and prompt for configuring Github action:

```bash
Your app 'snowy-disk-4284' has been configured successfully!
Do you want to configure a github action? [y/N]:
```

On confirming with `y` the CLI will create a `ploomber-cloud.yaml` file in the path `.github/workflows`.
In order to trigger an action for deploying the project using Github actions you need to add, commit and push this file along with the `ploomber-cloud.json`.

Once done, you can monitor progress as discussed [above](monitor). Ensure that the API key is set as Github secret.
Copy link
Contributor

Choose a reason for hiding this comment

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

add link here to the section that shows how to store the API key using github's UI


In case the [workflow template](https://github.com/edublancas/cloud-template/blob/main/.github/workflows/ploomber-cloud.yaml) has been updated, and you need to re-initialise the application the CLI will prompt your for updating the workflow file:
Copy link
Contributor

Choose a reason for hiding this comment

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

this point is unclear: project re-initialization doesn't happen often. the only case I can think of is if the project gets corrupted.

wouldn't it make more sense to check for an updated workflow file when calling ploomber-cloud deploy?

I see two scenarios:

  1. if ploomber-cloud deploy is running on github actions, then we can juts print a mesage
  2. if ploomber-cloud deploy is running locally, we can deploy and then prompt the user, asking if they want to update their ploomber-cloud.yaml

Copy link
Contributor Author

@neelasha23 neelasha23 Jan 16, 2024

Choose a reason for hiding this comment

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

Yes checking during deploy would make more sense. For scenario 1, the message will be displayed in the github actions logs?

I also had a doubt. Right now there is just a check to see if the repo workflow file contents is different from the template one. This might happen even if user removes the --watch flag from ploomber-cloud deploy --watch or changes the name of the workflow. So do we need to check these specific differences and only then prompt for updation ?

@edublancas

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought through this, here's my feedback (note that this workflow is different to what I proposed earlier cause I noticed some potential issues):

  • we can add a ploomber-cloud github command that can take care of configuring for the first time (if the file doesn't exist) or update the workflow (if it already exists)
  • then, when users run ploomber-cloud init or ploomber-cloud deploy, we can either thell them they can configure github deployment (or update their existing workflow) by running ploomber-cloud github

the reason I'm proposing this is because I feel like prompting users for an answer when running init or deploy might be annoying and unexpected. instead, we can just print some relevant message on init/deploy and they can decide if they want to configure/update github actions by running ploomber-cloud github

Last call is up to you; think what scenarios users will encounter and define the workflow that makes more sense

Copy link
Contributor Author

@neelasha23 neelasha23 Jan 17, 2024

Choose a reason for hiding this comment

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

Sure! I'll start implementing this and if I find any scenario which would be an issue , I'll discuss and modify accordingly.

Also, would it be better to store the last updated date in the workflow file? I haven't found a direct way of doing it in the docs, I still needs to explore if it's possible. Because of reasons I mentioned in the above comment:

Right now there is just a check to see if the repo workflow file contents is different from the template one. This might happen even if user removes the --watch flag from ploomber-cloud deploy --watch or changes the name of the workflow. So do we need to check these specific differences and only then prompt for updation ?

@edublancas

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok to tell the user to update only when the contents are different, no need for more complex implementation right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please refer to this comment

Copy link
Contributor

Choose a reason for hiding this comment

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

let's keep spelling consistent:

re-initialise -> re-initialize
github -> GitHub

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added more mentions of GitHub in the latest commit.


```bash
Your app 'red-river-8187' has been configured successfully!
.github/workflows/ploomber-cloud.yaml seems outdated. Do you want to configure a github action? [y/N]:
```

Please review the workflow file and update if needed.