DEV Community

Cover image for Automating My Deploys From GitHub to Glitch

Automating My Deploys From GitHub to Glitch

Melissa McEwen on April 21, 2020

Programmers love automation. Anything we have to do over and over again? Automate it! One of these tasks I've been working to automate is deploying...
Collapse
 
bacongravy profile image
David Kramer

Thank you! This article is awesome!

I was so inspired by the technique you describe that I created a new project, glitcheroo. It lets you deploy an app from a local git repository to a remote Glitch project, kind of like Heroku.

Collapse
 
melissamcewen profile image
Melissa McEwen

Whoa, I'm totally gonna check this out, it sounds awesome.

Collapse
 
bacongravy profile image
David Kramer

I wrote up an introduction here: dev.to/bacongravy/introducing-glit...

I'd love your feedback.

Thread Thread
 
melissamcewen profile image
Melissa McEwen

Reading now + sharing with my colleagues!

Thread Thread
 
bacongravy profile image
David Kramer

Coming full circle, I also created a project to demonstrate how to use glitcheroo from a GitHub Actions workflow: github.com/bacongravy/useful-insect

This is the interesting part:

      - name: Deploy project to Glitch
        run: |
          npx glitcheroo deploy
        env:
          GLITCHEROO_GIT_URL: ${{ secrets.GLITCHEROO_GIT_URL }}
Collapse
 
dtinth profile image
Thai Pangsakulyanont

Thanks you for this! This Git hook is the missing piece for me to sync changes from GitHub to Glitch directly.

So far I tend to do the other way around, editing and prototyping stuff in Glitch and have it synchronized to GitHub. I have a central repo that runs every morning (on GitHub Actions) to sync my 10+ Glitch projects to GitHub. With this, now I know how to do a two-way sync, yay!

By the way, should the Git hook also run refresh so that changes are reflected in the Glitch editor in case someone is viewing it? Are there any pitfalls of doing that?

Collapse
 
melissamcewen profile image
Melissa McEwen

Ah good idea, I think adding Refresh would help in case you have it open in the editor. I'll try it out.

Collapse
 
jpcarrascal profile image
JP Carrascal

This article was super helpful!
I managed to set two Glitch projects to behave like my development and production environments, with my main repo being in GitHub and everything working CI/CD style. Thank you very much!

I have three comments:

  • I'd clarify that the GitHub action uses somebody else's code from github.com/wei/git-sync
  • The GitHub repo should be public. Otherwise you need to also set a SSH public key as explained in the link above.
  • Minor: In the article you say "Replace YOUR GITHUB REPO URL HERE with your https GitHub URL", but there is no "YOUR GITHUB REPO URL HERE" in the action code (although the solution is obvious :)

Cheers!

JP

Collapse
 
melissamcewen profile image
Melissa McEwen

Thanks for the feedback, just made some edits as suggested :D

Collapse
 
itshi32 profile image
itshi

one point wei has update his workflow since post
other point folowing article i got DESTINATION=***:master
Cloning into '/root/source'...
fatal: could not read Username for 'github.com': No such device or address
fatal: not a git repository (or any parent up to mount point /github)

Collapse
 
khalby786 profile image
khaleel gibran
Collapse
 
melissamcewen profile image
Melissa McEwen

Thanks! That one is interesting too. I needed a solution that didn't alter the code to the project because for example the project in question here is really just a repo of Markdown files and I wanted to keep it that way.