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

Using firelink in GitHub actions #45

Closed
yaron1m opened this issue Mar 12, 2022 · 8 comments
Closed

Using firelink in GitHub actions #45

yaron1m opened this issue Mar 12, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@yaron1m
Copy link

yaron1m commented Mar 12, 2022

Hi,

I want to deploy my firebase functions from Github Actions.
Until I started using firelink I used w9jds/firebase-action, but this does not work with firelink.

How can I deploy my firebase functions from GitHub actions using firelink?
Are there plans to create a dedicated action for firelink?

Alternatively, is there an option to run firelink without the actual deployment (i.e. just the file generation)? I would love an option to run firelink --onlyCopyFiles and then run the action above.

Thanks!

@Stradivario
Copy link
Member

Stradivario commented Mar 13, 2022

Hello there @yaron1m and thank you for the ticket!

I think what you need to do is just run firelink without any arguments until i think of better solution and test out some scenarios with this github action. Notice the job for Copy packages with Firelink it should be pretty simple but i need to test it out.

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Install Dependencies
        run: npm install
      - name: Copy packages with Firelink
        run: npx firelink
      - name: Build
        run: npm run build-prod
      - name: Archive Production Artifact
        uses: actions/upload-artifact@master
        with:
          name: dist
          path: dist

Stay tuned

Regards,
Kristiyan Tachev

@Stradivario Stradivario self-assigned this Mar 13, 2022
@Stradivario Stradivario added enhancement New feature or request good first issue Good for newcomers labels Mar 13, 2022
@yaron1m
Copy link
Author

yaron1m commented Mar 13, 2022

Thanks @Stradivario!

This solution is almost working. It does create the .packages folder correctly but is missing one part - changing the path of the dependency library from ^1.0.0 to file:..., this the deployment still fails.

I managed to solve that by running firelink --leave-changes in the action:

      - name: Install firelink
        run: npm i -g @rxdi/firelink

      - name: Run firelink
        working-directory: ./firebase/functions
        run: npx firelink --leave-changes

      - name: Deploy to Firebase Functions
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only functions
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

But, this also fails, because it expects firebase-tools to be installed. I also notice that after running firelink the output is similar to running firebase --help which is a bit confusing.

Run firelink --leave-changes
  firelink --leave-changes
  shell: /usr/bin/bash -e ***0***
command not found: firebase
Error: Process completed with exit code 1.

My temporary solution to this was to also install firebase-tools globally

      - name: Install deployment dependencies
        run: npm i -g @rxdi/firelink firebase-tools

Here's what I suggest:
Create a new flag for firelink - --onlyCopyFiles (or any other name) that will:

  1. Copy the files to .packages.
  2. Edit package.json and create the backup file.
  3. Not trigger firebase in any way.

What do you think?

@Stradivario
Copy link
Member

Stradivario commented Mar 16, 2022

Hello there @yaron1m !

I just created a PR with i hope that this will be the appropriate way to fix your issue.

The command that you are looking for will be:

firelink --no-runner --leave-changes

This command i think will satisfy all 3 needs written

  1. Copy the files to .packages.
  2. Edit package.json and create the backup file.
  3. Not trigger firebase in any way.

If you do want to revert changes u can use command --revert-changes

firelink --no-runner --revert-changes

If you want just to prepare the environment and do the magic of firelink this command will just not execute the defined script at the end aka firebase which is by default or other predefined inside fireConfig.runner

firelink --no-runner

Expect a version bump in about an hour!

Cheers and please tell me if this command is working for you so we can close that ticket :)

Feel free to contact me for any details regarding anything :)

Cheers,
Kristiyan Tachev

@yaron1m
Copy link
Author

yaron1m commented Mar 16, 2022

Nice!

I will give it a try in the next few days and let you know if this is working :)

Thank you for your great work!
Yaron

@Stradivario
Copy link
Member

Stradivario commented Mar 16, 2022

@yaron1m awesome mate i appreciate it a lot!

But, this also fails, because it expects firebase-tools to be installed. I also notice that after running firelink the output is similar to running firebase --help which is a bit confusing.

One thing i didn't answer is that firebase command is the default runner and this is why by default requires firebase-tools
I think this should change in the future and remove the need for command to be executed if not specified. That way this library can be used with any tool or workflow.

I am preparing now a PR with complete refactoring of the code since i wasn't prepared for such an attention regarding this library and we need to move faster in order to be easy for usage and development. U can track the progress here for the actual refactoring.

#47 #48

Library will be refactored using Functional programming approach and i will provide some useful tools like UI that can be added as a Plugin to the system.

You can install the new version with npm install @rxdi/[email protected]

Regards!

@yaron1m
Copy link
Author

yaron1m commented Mar 17, 2022

I just tested this and it worked great:

      - name: Install deployment dependencies
        run: npm i -g @rxdi/firelink

      - name: Run firelink
        working-directory: ./firebase/functions
        run: firelink --no-runner --leave-changes

      - name: Deploy to Firebase Functions
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only functions
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

Thank you!

@Stradivario
Copy link
Member

Stradivario commented Mar 17, 2022

I just tested this and it worked great:

      - name: Install deployment dependencies
        run: npm i -g @rxdi/firelink

      - name: Run firelink
        working-directory: ./firebase/functions
        run: firelink --no-runner --leave-changes

      - name: Deploy to Firebase Functions
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only functions
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

Thank you!

Oh man that looks like "pure ore" i like it how clean it is !

I am glad you create this ticket and help the library to become better ! Thanks !

Cheers!

EDIT: I am thinking even to add this example inside the readme so more people will know how to do that !

@Stradivario
Copy link
Member

Feel free to open this issue again if needed!

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants