Using environment in github actions without creating Deployments
#36919
-
|
I have environment-specific secrets defined which I'd like to reference from my Action. I think this requires me to set an |
Beta Was this translation helpful? Give feedback.
Replies: 99 comments 54 replies
-
|
what do you mean by accessing env variables? those are just there for your jobs to consume them, they are not triggering anything whatsoever, if you can share your yml would be nice |
Beta Was this translation helpful? Give feedback.
-
|
Hi there @connor-luna and welcome to our community 😄. Thanks so much for asking a great question! |
Beta Was this translation helpful? Give feedback.
-
|
I would also love it if we could use Environments for setting up repeatable workflows without every Job that references an I have a complex multi-job setup in a monorepo that utilizes matrices for concurrent steps. These matrix jobs reference an The problem is that I have, is my workflow creates 40+ jobs related to an Each update to a PR adds another set of 40+ messages into the PR history. This completely buries any conversion in PR because of the interface hiding messages for you. This is a public repo, so you can see the workflow here: Here's an example PR where Deployments noise, hides active important conversations. |
Beta Was this translation helpful? Give feedback.
-
|
We also find this frustrating. We run a number of environment-specific checks as part of pull request tests and they are shown in the UI as having deployed to environments where they have not truly been. It would be great to have the ability to distinguish "prepare deployment" or "verify deployment" or similar read-only operations from an actual "deploy to environment" update action. (worth noting that there's prior art here: GitLab supports this distinction: https://docs.gitlab.com/ee/ci/environments/#access-an-environment-for-preparation-or-verification-purposes) |
Beta Was this translation helpful? Give feedback.
-
|
Same frustration here. I need to access Environment secret for a Terraform Plan job, but of course nothing is being deployed at that stage. And to make it worse we have have enabled human approval for some environments so we have to manually approve Terraform plans, which is obviously a bit daft and a waste of time |
Beta Was this translation helpful? Give feedback.
-
|
Same issue here |
Beta Was this translation helpful? Give feedback.
-
|
Another thumbs up for this issue. It would be nice to get some feature that would let you specify if the workflow should create a "deploy" or not |
Beta Was this translation helpful? Give feedback.
-
|
Same issue! I just want to have access to the variables per env. |
Beta Was this translation helpful? Give feedback.
-
|
same issue, I have a workflow which deploys logic, and one which deploys infra using terraform - both use env secrets but now both look the same and cause "deployments" to be created. |
Beta Was this translation helpful? Give feedback.
-
|
Same issue, for us we have a docker image hosted in ECR but only in our prod account. We want to use it as a service container in our PR workflow test job but we need to login to ECR and get the docker password and secret in prod. So we have a job before the tests job that uses the "production" environment to get secrets for logging in to ECR. We haven't deployed anything just need the outputs but now all our PR's have marks saying they were deployed to prod even though they haven't been. 😞 Edit: Clean up wording |
Beta Was this translation helpful? Give feedback.
-
|
Same issue here, I'd like to decide when a successfully run action that references an environment creates or not a deployment. Mostly because I use environment over variables because they have approval. |
Beta Was this translation helpful? Give feedback.
-
|
same problem, anyone have a workaround? it's super annoying to have a terraform plan always trigger a "deployment" when nothing is being deployed at all. |
Beta Was this translation helpful? Give feedback.
-
|
Same here. I'm doing a dry run (Terraform) deploy into the target environment as part of a PR but then says it was deployed. It seems like a missing piece of the puzzle. |
Beta Was this translation helpful? Give feedback.
-
|
Same issue. |
Beta Was this translation helpful? Give feedback.
-
|
We have same issue here, |
Beta Was this translation helpful? Give feedback.
-
|
We also have a lot of frustration with this coming from the Terraform side. However, there's an another piece that is also adding friction. If you use these for deployment gates with their Protection rules, for some applications that require build-time secrets/variables, this can create multiple jobs that require approvals at each step (one for build stage, another for deploy stage). This adds unnecessary friction to the deploy process for getting a release out. This, combined with the terraform headaches, adds so much additional pipeline overhead that it makes the Environment feature more of a burden than a benefit. Consider the following: 2 Workflows:
This would end up requiring 4 approvals at the bare minimum. Multiply this by X number of environments you have, and you're going to go crazy. There's really no way to get around this for some applications without creating an absurd amount of noise (notifications, PR "deployments", etc), multiple "vanity" Environments that are strictly used for approval gates, or over complicated "hacky" workarounds as proposed above. Finally, it'd be great to reduce the number of deployments because we want to be able to easily compare what is recently deployed vs. previously deployed. While we already leverage tags for this, having those be more aligned with actual deploymnets would add a lot of value. Edit: This demonstrates a Job that gives you time to review the plan output and review proposed changes. The |
Beta Was this translation helpful? Give feedback.
-
|
+1 here, especially this comment as an idea: |
Beta Was this translation helpful? Give feedback.
-
|
The best workaround I came up with was setting the default |
Beta Was this translation helpful? Give feedback.
-
|
I came up with that workaround which works pretty well for me: |
Beta Was this translation helpful? Give feedback.
-
|
Given how many people are having this issue since 2023, I'd imagine GitHub prioritizes this issue. We're also struggling with the same mess everyone is. |
Beta Was this translation helpful? Give feedback.
-
|
I can't believe this still isn't possible. We wanted to structure our variables and secrets for our monorepo without having to add an app-specific prefix every single time. We simply wanted to build each app in our pull request action to verify it still works, but this creates a deployment for every single app, even though nothing is being deployed. |
Beta Was this translation helpful? Give feedback.
-
|
This is something our organization also desperately wants. There are several use cases where we want to use "environments" to fetch secrets/variables during build-time but without creating a github deployment, such as building for every stage at the start of a workflow, and conditionally deploying it in later stages, such as waiting for a test suite or manual approval. Also, we use reusable workflows ( We have resorted to splitting it out into a |
Beta Was this translation helpful? Give feedback.
-
|
This is something that should come by default with GitHub actions, but surprisingly and even after 3 years of complaints the feature is not there. It has a bad design, and it's even more noticeable for big monorepos. And this is not exactly related to the issue that was initially presented here, but the UI should automatically filter out deployment environments that you're not able to approve - it's such a small quality of life change that will be super helpful for big matrices that require deployment environments. |
Beta Was this translation helpful? Give feedback.
-
|
Come on GitHub, whats going on? Just copy the idea/design from GitLab? Or the simple idea suggested from the comments: Thats a none breaking change and an if statement check around the deployment functionality: There you go I've written it for you... not much to do now 😉 I am sure several of us will fix it for free if its a priortity or a budget issue.... |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for being quiet on this one, it is on our list still and we are seeing if it's something we can get to in the next few months <3 |
Beta Was this translation helpful? Give feedback.
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
no — not today. In GitHub Actions, environment-scoped secrets are inseparably tied to deployments. |
Beta Was this translation helpful? Give feedback.
-
|
This is now available. Hope you enjoy! It was fun to work on this feature for you all. Use jobs:
test:
runs-on: ubuntu-latest
environment:
name: staging
deployment: false
steps:
- run: echo "Staging secrets accessible, no deployment created"
env:
API_KEY: ${{ secrets.API_KEY }}What's not compatible: custom deployment protection rule apps (job will fail — remove Docs: |
Beta Was this translation helpful? Give feedback.



This is now available. Hope you enjoy! It was fun to work on this feature for you all.
Use
deployment: falseWhat's not compatible: custom deployment protection rule apps (job will fail — remove
deployment: falseor the custom rule).Docs: