Giter VIP home page Giter VIP logo

Comments (6)

MichaelCurrin avatar MichaelCurrin commented on June 2, 2024 1

I have a simplified example of artifacts if you need https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/ci-cd/github-actions/jobs.html#job-sequence

Checking for if github.base_ref is shorter but less clear what it is doing than if gitub.event_name != 'pull_request.

Also, you might get an error that the key is not set, since it says the attribute is not always available. Or maybe it will return nil or empty string.

from meli-docs.

gempain avatar gempain commented on June 2, 2024 1

Thanks for the example ! I'll have a look tomorrow 😄

Regarding the value, I'll run a few tests on a demo project to see how this behaves.

from meli-docs.

gempain avatar gempain commented on June 2, 2024

@MichaelCurrin as I was started to look at your PRs, I noticed this and fixed it even before I got to this issue, great minds meet 😄 Sorry for the hickup, it's something I was aware of but had pushed back on the todo list as PRs weren't coming in this fast 😄

Using an if would be a good solution, but I went with a slightly different method. I created two workflows: one for PRs and another one for pushes. This has the advantage of letting any member of this project to deploy previews while external PRs will skip preview deployments.

You've actually pointed out something that has been bugging me for a while: Meli currently allows you to preview PRs for members of your project, but external PRs cannot be previewed because as you rightly pointed out, GH actions runs on your side and you don't have the secret to push to the repo. This is something I'd like to find a way around for Github - the problem doesn't happen on CircleCI and others, it's specific to how GH Actions works, which is quite interesting I think). I like how GH actions does CI because it prevents anyone to actually try to steal your secrets, which is something doable on most other CIs - and I don't understand why no one has actually started looking into this deeper, most of them delegate security management to the user.

The main problem is that letting external PRs deploy could allow anyone to start clogging your Meli's server with who-knows-what. Also, at the moment, site tokens allow you to override any branch, which means a PR could try to override your main branch. We'd need to introduce a new setting on tokens which would toggle on/off the ability to change the main branch, this way you could allow deploys on those external branches with a less destructive token.

Another solution would be to use webhooks. This way, when a PR comes in, Meli can download the content of the branch and load a preview. This would be the safest I think.

from meli-docs.

MichaelCurrin avatar MichaelCurrin commented on June 2, 2024

Ok good, glad you've got the two workflows idea then.

I had thought of two workflow files before for my own projects. But it means that any common steps like install, build and test get duplicated on two files and you have to remember to change both.

You can also use two jobs in one workflow file, and have the deploy job depend on on the install_build_test job, and you can set a condition on the deploy job itself (not just a step) run only on a push. But you have to do work to store output of one job and open it in the open job.

from meli-docs.

MichaelCurrin avatar MichaelCurrin commented on June 2, 2024

Regarding GH Actions, checkout out the Actions tab on Settings. Perhaps you want to try something more secure to stop anyone making a potentially dangerous PR when making a deploy preview.

This looks like you define the Action that is used - one within your org, a GitHub one, a marketplace action which needed to approval or a named action. This does NOT look like it cares whether the workflow runs on the original repo or on a fork.


Screen Shot 2021-01-11 at 2 38 15 pm


I believe GH Actions and Netlify will also strip out a token from the logs for security, but of course someone could try send it somewhere else (like adding their own malicious action to the workflow and passing and storing the token).

I am not so familiar with webhooks.

from meli-docs.

gempain avatar gempain commented on June 2, 2024

Ok good, glad you've got the two workflows idea then.

I had thought of two workflow files before for my own projects. But it means that any common steps like install, build and test get duplicated on two files and you have to remember to change both.

You can also use two jobs in one workflow file, and have the deploy job depend on on the install_build_test job, and you can set a condition on the deploy job itself (not just a step) run only on a push. But you have to do work to store output of one job and open it in the open job.

Right on 😄 the two workflows is a bit tedious as we're duplicating the basis, but here it's fine with me as it's just a few lines.

The multi-job approach is definitely cleaner, it was just quicker to have two workflows, but I just looked a bit more into this, and we could do an if statement on the second job with github.base_ref. We can then use artifacts for pass the build dir between both jobs.

I believe GH Actions and Netlify will also strip out a token from the logs for security, but of course someone could try send it somewhere else (like adding their own malicious action to the workflow and passing and storing the token).

Correct. It's a serious issue for many CIs. GH's way of doing it is really nice.

from meli-docs.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.