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

Updating the deploy-preview.yml #12

Merged
merged 5 commits into from
May 8, 2024
Merged

Conversation

clarkbw
Copy link
Contributor

@clarkbw clarkbw commented May 7, 2024

Moving to use $GITHUB_ENV which should work for the migrate and deploy steps

Dropping some of the top level env variables.

Moved NEON_PROJECT_ID from secret to var

Moving to use $GITHUB_ENV which should work for the migrate and deploy steps

Dropping some of the top level env variables.

Moved NEON_PROJECT_ID from secret to var
@clarkbw clarkbw requested a review from m-abdelwahab May 7, 2024 15:44
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Required for commenting on pull requests for private repos
NEON_API_KEY: ${{ secrets.NEON_API_KEY }} # You can generate a an API key in your account settings
NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} # You can find this in your project settings
NEON_PROJECT_ID: ${{ var.NEON_PROJECT_ID }} # You can find this in your Neon project settings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will require you moving the NEON_PROJECT_ID from secrets over to vars but it's not a protected secret so I think that's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we move NEON_PROJECT_ID to vars it no longer needs to be listed up here. However I think it's good to have here so we can explain where it came from.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea I'm a fan of listing variables at the top of the workflow

@@ -21,46 +19,40 @@ jobs:
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js 18
uses: actions/setup-node@v4
- uses: actions/setup-node@v4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to code comments, I only like them when they are stating a reason that's not obvious. Otherwise they're superfluous.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense

.github/workflows/deploy-preview.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-preview.yml Outdated Show resolved Hide resolved
run: |
touch .env
username: ${{ secrets.NEON_DATABASE_USERNAME }} # change to your Neon database username / role
api_key: ${{ secrets.NEON_API_KEY }} # Generate a an API key in your Neon account settings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this away from the env header because otherwise all the previous steps have access to this secret. Ideally we only expose it to the actions who need it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense


echo DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}?sslmode=require >> .env
- run: |
echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}?sslmode=require" >> "$GITHUB_ENV"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels cleaner to me compared to creating the .env file. And it should work the same way... testing needed.

uses: superfly/[email protected]
with:
secrets: DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require
secrets: DATABASE_URL=$DATABASE_URL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be picking up the env variable created with the >> $GITHUB_ENV step.


- name: Comment on Pull Request
uses: thollander/actions-comment-pull-request@v2
with:
# GITHUB_TOKEN: ${{ env.GH_TOKEN }} # Required for commenting on pull requests for private repos
message: |
Fly Preview URL :balloon: : ${{ steps.deploy.outputs.url }}
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }}
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ env.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulls from the env variable at the top of the file instead of the secret directly.

@clarkbw
Copy link
Contributor Author

clarkbw commented May 7, 2024

Looks good to me!

m-abdelwahab and others added 4 commits May 7, 2024 19:41
Use the var.NEON_PROJECT_ID to match
Truncate step names
Move env variables for this one down to the steps that require them. We've explained in other files where they are needed.
Co-authored-by: Bryan Clark <[email protected]>
@m-abdelwahab m-abdelwahab merged commit 0ba78e8 into main May 8, 2024
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.

None yet

2 participants