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

ci: trigger GitLab deployment pipeline when pushing #186

Merged
merged 21 commits into from
Dec 21, 2024
Merged

Conversation

bolinocroustibat
Copy link
Contributor

@bolinocroustibat bolinocroustibat commented Oct 2, 2024

Closes datagouv/data.gouv.fr#1465.
Goes hand-to-hand with the GitLab MR.

For now, the trigger is sent only when we push on main.
We can imagine other policies?

EDIT:

Refactored entirely to use the GitLab scaffolding deploy script repository instead, as the intermediary between this CI and GitLab API for infra repo CI.

Remarks:

  • As a first version, this only triggers a call to the deploy script (and thus to GitLab for deploying on dev environment) when pushing on main. Later, we can imagine deploying easily, I suggest to do it in another PR.
  • This PR also includes a better separation of the build job into smaller steps, clearer and easier to debug. This cleaning job can be more clearly done in this dedicated PR #238, so if easier to review we can review and merge #238 before the present one
  • Once merged, we will do the same thing on repo udata and any other suggested
  • This has been partially tested, it successfully triggers the simple-scaffold script: https://app.circleci.com/pipelines/github/datagouv/hydra/1765/workflows/d04e28c0-7bf3-481f-af57-c0f660be8ab0/jobs/6328. It needs to be rested with the full workflow, once the GitLab API integration in CI is ready on infra's side.

@bolinocroustibat bolinocroustibat changed the title ci: add step to trigger GitLab ci: trigger GitLab when pushing on main Oct 2, 2024
@bolinocroustibat bolinocroustibat changed the title ci: trigger GitLab when pushing on main ci: trigger GitLab deployment when pushing on main Oct 2, 2024
@bolinocroustibat bolinocroustibat self-assigned this Oct 2, 2024
@bolinocroustibat bolinocroustibat force-pushed the auto-deploy branch 6 times, most recently from d223da7 to 3012f24 Compare October 3, 2024 08:17
@bolinocroustibat bolinocroustibat changed the title ci: trigger GitLab deployment when pushing on main ci: trigger GitLab deployment when pushing Oct 3, 2024
@bolinocroustibat bolinocroustibat marked this pull request as ready for review October 3, 2024 08:23
@bolinocroustibat bolinocroustibat force-pushed the auto-deploy branch 3 times, most recently from 88f28df to 413b54d Compare October 3, 2024 11:19
@bolinocroustibat bolinocroustibat changed the title ci: trigger GitLab deployment when pushing ci: trigger GitLab deployment pipeline when pushing Oct 3, 2024
@bolinocroustibat bolinocroustibat force-pushed the auto-deploy branch 4 times, most recently from 414f54d to 8e1a867 Compare October 3, 2024 12:11
@maudetes
Copy link
Contributor

maudetes commented Oct 3, 2024

I'd be willing to speak about the process live! I think having the job run after the publish would allow us to deploy the right pypi .dev version :)

Copy link
Contributor

@magopian magopian left a comment

Choose a reason for hiding this comment

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

Looks nice! Does it work? Is there any way to test it before it's merged in prod?

@bolinocroustibat
Copy link
Contributor Author

I'd be willing to speak about the process live! I think having the job run after the publish would allow us to deploy the right pypi .dev version :)

Makes sense. Just updated so that the "deploy" job runs after the "publish" job and depends on it. LMKWYT!

@bolinocroustibat bolinocroustibat force-pushed the auto-deploy branch 2 times, most recently from 95e0156 to f3e1dfd Compare November 5, 2024 16:59
Copy link
Contributor

@maudetes maudetes left a comment

Choose a reason for hiding this comment

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

🚀 I will let @jordanguedj approve but it seems readable to me! Great job!

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@bolinocroustibat bolinocroustibat force-pushed the auto-deploy branch 2 times, most recently from 46ccf70 to fd4307a Compare December 20, 2024 03:51
Copy link
Contributor

@jordanguedj jordanguedj left a comment

Choose a reason for hiding this comment

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

Thanks for this!
However, even if we don't want to run this pipeline for another environment than dev (for now), this version of .circleci/config.yml will only and always apply to dev (dev environment shouldn't be hard-coded). IMO, we should have something dynamic and ready to handle other environments.

.circleci/config.yml Outdated Show resolved Hide resolved
@bolinocroustibat bolinocroustibat merged commit 8a6f6d7 into main Dec 21, 2024
4 checks passed
@bolinocroustibat bolinocroustibat deleted the auto-deploy branch December 21, 2024 10:07
bolinocroustibat added a commit to opendatateam/udata that referenced this pull request Jan 9, 2025
…#3232)

Similar to datagouv/hydra#186 on Hydra, this PR adds automatic deployment by triggering GitLab infra CI through the `simple-scaffolding` script.

- Add job `trigger-gitlab-pipeline` using `simple-scaffolding` deploy script
- Add CI parameters `python-version`, `publish-branch` and `deploy-env`
- Build the version number in build job and persists it in a file to be used by `trigger-gitlab-pipeline`
- Split the build job into smaller, more explicit steps for better debugging and readability
- Rename workflow to avoid confusion with building job and to be more explicit

This CI needs:
- `SCAFFOLD_PRIVATE_KEY` to be created and added 
    [x] private one to be added as CircleCI env
    [x] public one to be added on simple-scaffold GitLab repo
- `GITLAB_API_TOKEN` to be created and added
    [x] on GitLab infra API tokens
    [x] on CircleCI env
bolinocroustibat added a commit to datagouv/udata-front that referenced this pull request Jan 10, 2025
…#632)

Similar to datagouv/hydra#186 on Hydra, this PR adds automatic deployment by triggering GitLab infra CI through the simple-scaffolding script.

- Add `trigger-gitlab-pipeline` job using `simple-scaffolding` deploy script and the existing `$BUILDNO` var
- Add CI parameters `publish-branch` and `deploy-env`
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.

[hydra] Deploy udata automatically on dev.data.gouv.fr when pushing on branch main of udata GitHub repo
4 participants