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

Skip automatic deployment job if secrets aren't set (especially for forks) #32

Merged
merged 2 commits into from
Apr 14, 2024

Conversation

ctmbl
Copy link
Contributor

@ctmbl ctmbl commented Mar 5, 2024

to test it properly i have to push this comit to my main branch on my own fork
I also added a smoke test fake secret to test it here

@ctmbl ctmbl linked an issue Mar 5, 2024 that may be closed by this pull request
@ctmbl ctmbl force-pushed the skip-deploy-on-fork branch 2 times, most recently from dca6d38 to 6472b2c Compare March 6, 2024 00:07
@ctmbl ctmbl added the bug Something isn't working label Mar 21, 2024
@ctmbl ctmbl force-pushed the skip-deploy-on-fork branch 2 times, most recently from 2fed1a5 to 948b08f Compare April 14, 2024 17:37
@ctmbl
Copy link
Contributor Author

ctmbl commented Apr 14, 2024

EDIT: since #57 (comment) I had to update this solution because some things were flawed

I've been down the rabbit hole and it seems to be no nice way to do what I want to do here.

TLDR:

Workflow syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env

see DISCLAIMER comment
add required secrets in comment
@ctmbl ctmbl force-pushed the skip-deploy-on-fork branch from 948b08f to 7d1b42a Compare April 14, 2024 18:06
On main branch the condition on the deploy step was:
github.event_name == 'push' || github.event_name == 'workflow_dispatch'

It must be resolved given that we want to avoid triggering on forks (due
to possibly missing secrets leading to failing workflow)
it then become:
(github.event_name == 'push' && github.event.repository.fork == 'false') || github.event_name == 'workflow_dispatch'
<==>
If it is a classic push:
- on fork *do not* trigger deployment
- on base repo trigger deployment
But if it is manually triggered, execute deployment step anyway
maybe we're on fork maybe we're not but this is user triggered so it the
user's responsability anyway.
@ctmbl ctmbl merged commit 85efd32 into iScsc:main Apr 14, 2024
3 of 4 checks passed
@ctmbl ctmbl deleted the skip-deploy-on-fork branch April 14, 2024 18:24
ctmbl added a commit that referenced this pull request Apr 14, 2024
see DISCLAIMER comment
add required secrets in comment

On main branch the condition on the deploy step was:
github.event_name == 'push' || github.event_name == 'workflow_dispatch'

It must be resolved given that we want to avoid triggering on forks (due
to possibly missing secrets leading to failing workflow)
it then become:
(github.event_name == 'push' && github.event.repository.fork == 'false') || github.event_name == 'workflow_dispatch'
    <==>
If it is a classic push:
 - on fork *do not* trigger deployment
 - on base repo trigger deployment
But if it is manually triggered, execute deployment step anyway
maybe we're on fork maybe we're not but this is user triggered so it the
user's responsability anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable deployment workflow in forks
1 participant