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

V2 Migration #47

Merged
merged 28 commits into from
Jun 5, 2024
Merged

V2 Migration #47

merged 28 commits into from
Jun 5, 2024

Conversation

AndrewKahr
Copy link
Member

@AndrewKahr AndrewKahr commented Apr 22, 2023

Changes

  • Rollback node-fetch version
  • Add test deployment
  • Use service account for deployment
  • Update node to 20 (Current version shuts down in 6 months)
  • Complete migration to v2 (Defaults to v2 in ~3 months)
  • Update packages

This should merge before working on fixing #48. Prior to merging, all existing functions will need to be deleted as updating to v2 cannot be done in place.

Checklist

  • Read the contribution guide and accept the code of conduct
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)

@AndrewKahr
Copy link
Member Author

@webbertakken Is there a way to test deployments in a workflow without actually deploying? The build workflow was a green light but the previous deployment failed.

@webbertakken
Copy link
Member

webbertakken commented Apr 22, 2023

@webbertakken Is there a way to test deployments in a workflow without actually deploying? The build workflow was a green light but the previous deployment failed.

Nowadays there is an action that does preview deployments for firebase. It wasn't there when I created this. I have in fact just set that up in another repo of mine and it works well (you would still need to do something based on the env so that the ingeminator code doesn't do stuff in prod though)

@AndrewKahr
Copy link
Member Author

I assume you mean don't let the ingeminator do stuff in the preview deployments and only allow it in prod? Curious if you have any ideas off the top of your head on how to accomplish this.

Would you also be able to set up the service credentials as even if we don't use this action in the end, the one we currently use also complains about the login token being deprecated.

@webbertakken
Copy link
Member

webbertakken commented Apr 22, 2023

It does all of that stuff for you when you run firebase init. You have admin access to the project so you should be able able to provision the service account etc (it goes automatically).

And you can use https://github.com/webbertakken/brioso as reference if you like.

@AndrewKahr
Copy link
Member Author

Wouldn't I need access to secrets on the versioning-backend repo to add the credential after running init? Or am I supposed to run init in a workflow on GitHub?

@webbertakken
Copy link
Member

webbertakken commented Apr 22, 2023

You have editor access in the project

edit: removed public email in screenshot

I'm not sure what you mean by needing access. Could you be very specific?

@AndrewKahr
Copy link
Member Author

I assume I need to access the secrets tab in the repo settings to be able to add the service account credentials but I can't see the settings tab as an editor, I believe I would need maintainer level access.

@webbertakken
Copy link
Member

No, you have to run firebase init and choose yes when it asks you to create a deployment workflow for you.

@webbertakken
Copy link
Member

I have also given you maintainer access on the repo.

@AndrewKahr
Copy link
Member Author

AndrewKahr commented Apr 22, 2023

I'm getting this error:

? For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) game-ci/versioning-backend

Error: HTTP Error: 403, Policy update access denied.

It sounds like I need even more permissions? https://stackoverflow.com/questions/63995958/firebase-init-functions-returns-403-caller-does-not-have-permission

It may also only be possible for an owner to init based on this: https://stackoverflow.com/questions/74860122/firebase-init-hosinggithub-for-organization

@webbertakken
Copy link
Member

Ok I've made you owner

@AndrewKahr AndrewKahr requested review from webbertakken and removed request for webbertakken April 22, 2023 23:34
@AndrewKahr
Copy link
Member Author

AndrewKahr commented Apr 22, 2023

The cleanup step claims there is an error deleting the artifact but manually going to the artifact page shows that it did indeed clean up the build artifact so I'm not sure what it's warning about. This should be ready to go now though

@AndrewKahr AndrewKahr changed the title Fix issues discovered during deployment V2 Migration Jun 4, 2024
Copy link
Member

@webbertakken webbertakken left a comment

Choose a reason for hiding this comment

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

LGTM.

Just make sure we have a backup of the database before the modified cron starts

package.json Outdated
Comment on lines 31 to 32
"devDependencies": {
"firebase-tools": "^13.10.2"
Copy link
Member

Choose a reason for hiding this comment

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

This should be installed as a global dependency as per the official docs

Comment on lines +43 to +66
testDeploy:
name: Test Deploy
needs: [test, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: install dependencies
run: yarn && yarn --cwd ./functions
- name: Deploy test to Firebase
uses: w9jds/firebase-action@v13.10.2
with:
args: deploy --only functions:testFunction
env:
GCP_SA_KEY: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_UNITY_CI_VERSIONS }}'
- name: Cleanup Firebase Test
uses: w9jds/firebase-action@v13.10.2
with:
args: functions:delete testFunction --force
env:
GCP_SA_KEY: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_UNITY_CI_VERSIONS }}'
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would want to keep it as this is a great way to ensure the project will deploy properly for the actual functions since it requires roughly the same permissions as the main functions and has been setup to require all the secrets that the other functions might use as a deploy test

}

static async becomeReady(): Promise<void> {
async becomeReady(): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

This is usually called init or create or getInstance, or made private and called from the constructor.

Comment on lines 86 to 92
GCP_SA_KEY: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_UNITY_CI_VERSIONS }}'
- name: Cleanup Firebase Test
uses: w9jds/firebase-action@v13.10.2
with:
args: functions:delete testFunction --force
env:
GCP_SA_KEY: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_UNITY_CI_VERSIONS }}'
Copy link
Member

Choose a reason for hiding this comment

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

Better to use --except flag and deploy in a single transaction, than to later delete a partial deployment.

@AndrewKahr AndrewKahr merged commit bd3002f into main Jun 5, 2024
4 checks passed
@AndrewKahr AndrewKahr deleted the fix-deployment branch June 5, 2024 02:55
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.

2 participants