Hey I read a few threads here and some mostly-outdated online articles about how to automate deployments from Github to Glitch, and just thought I would share my copy & paste solution.
This will wipe away any code in your Glitch project and replace it with the code from Github, and reload your project, every time you push to your repo’s
main
branch.
In your Glitch project:
- Go to the Glitch
đź’» Terminal
and run the following:
git config receive.denyCurrentBranch ignore
cat << EOF > .git/hooks/post-receive
unset GIT_INDEX_FILE
git --work-tree=/app --git-dir=/app/.git checkout -f
refresh
EOF
chmod u+x .git/hooks/post-receive
- Go to
🧰 Tools
, thenImport / Export
, and click the[ Copy ]
button to copy your project’s Git URL to clipboard.
In your Github repo:
-
Go to
⚙️ Settings
, thenSecrets and variables > Actions
, and click[ New repository secret ]
to add the following secret:- Name:
GLITCH_GIT_URL
- Secret:
✨ your project's Git URL ✨
(see previous step)
- Name:
-
Create a new Github Action, by committing a new file,
.github/workflows/sync.yml
:
name: Glitch Sync
on:
push:
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Sync to Glitch Project
uses: wei/git-sync@v3
with:
source_repo: https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
source_branch: main
destination_repo: ${{ secrets.GLITCH_GIT_URL }}
destination_branch: master
This Github Action will run every time you push to your repo’s main
branch, and will update and refresh your Glitch project automatically.