All Projects β†’ javierarce β†’ glitchub

javierarce / glitchub

Licence: MIT license
A step by step guide on how to keep a Glitch project in sync with a GitHub repo

Projects that are alternatives of or similar to glitchub

Webhook
webhook is a lightweight incoming webhook server to run shell commands
Stars: ✭ 7,201 (+23129.03%)
Mutual labels:  webhooks, deploy
sre.surmon.me
πŸ’» SRE service for Surmon.me blog.
Stars: ✭ 34 (+9.68%)
Mutual labels:  webhooks, deploy
deploy shard mongodb
This repository has a set of scripts and resources required for deploying MongoDB replicated sharded cluster.
Stars: ✭ 17 (-45.16%)
Mutual labels:  deploy
pydocker
Easy generator Dockerfile for humans
Stars: ✭ 29 (-6.45%)
Mutual labels:  deploy
kubewise
Get Helm notifications in your team chat
Stars: ✭ 52 (+67.74%)
Mutual labels:  webhooks
QLD
A graphical tool to make the deploying of Qt quick applications on linux platform faster
Stars: ✭ 18 (-41.94%)
Mutual labels:  deploy
epf-transmitter
astrizhachuk.github.io/epf-transmitter/
Stars: ✭ 32 (+3.23%)
Mutual labels:  deploy
cfn-deploy
A useful GitHub Action to help you deploy cloudformation templates
Stars: ✭ 14 (-54.84%)
Mutual labels:  deploy
takomo
Organize, parameterize and deploy your CloudFormation stacks
Stars: ✭ 27 (-12.9%)
Mutual labels:  deploy
nocd
πŸ„ δΈ€δΈͺθ½»ι‡ε―ζŽ§ηš„ζŒη»­δΊ€δ»˜η³»η»Ÿγ€‚ζ”―ζŒ Git ιƒ¨η½²γ€δΊ€δ»˜ι€šηŸ₯γ€δΈ­ζ–­δΊ€δ»˜γ€‚
Stars: ✭ 59 (+90.32%)
Mutual labels:  deploy
XUnityDeploy
Compile Unity to iOS[Android] client
Stars: ✭ 18 (-41.94%)
Mutual labels:  deploy
react-preview
a GitHub App built with probot that generates preview links for react based projects.
Stars: ✭ 14 (-54.84%)
Mutual labels:  webhooks
tradingview-webhooks
Backend service converting tradingview alerts into action.
Stars: ✭ 44 (+41.94%)
Mutual labels:  webhooks
Bybit-Auto-Trading-Bot-Ordes-placed-via-TradingView-Webhook
Python based Trading Bot that uses TradingView.com webhook JSON alerts to place orders(buy/sell/close/manage positions/TP/SL/TS etc.) on Bybit.com. Hire me directly here https://www.freelancer.com/u/Beannsofts for any assistance
Stars: ✭ 235 (+658.06%)
Mutual labels:  webhooks
ngx-aws-deploy
β˜οΈπŸš€ Deploy your Angular app to Amazon S3 directly from the Angular CLI πŸš€β˜οΈ
Stars: ✭ 84 (+170.97%)
Mutual labels:  deploy
discord-twitter-webhooks
πŸ€– Stream tweets to Discord
Stars: ✭ 47 (+51.61%)
Mutual labels:  webhooks
marathon-slack
Integration for Marathon's Event Bus with Slack
Stars: ✭ 42 (+35.48%)
Mutual labels:  webhooks
docker-wordmove
Docker image to run Wordmove
Stars: ✭ 16 (-48.39%)
Mutual labels:  deploy
temporalis
Slit-scan webcam with canvas
Stars: ✭ 105 (+238.71%)
Mutual labels:  glitch
heroku-deploy
A simple action to build, push and deploy your dockerized app to your Heroku Application
Stars: ✭ 40 (+29.03%)
Mutual labels:  deploy

How to keep a Glitch project in sync with a GitHub repo

You can follow the "initial steps" below or just remix this glitch project and continue in the next section.

Click here to reveal the initial steps
  1. Go to glitch.com and create a new hello-express app.
  2. Open the package.json file and add the following packages:
  • node-cmd
  • body-parser
  1. Open the server.js file and load the following libraries:
const cmd = require('node-cmd');
const crypto = require('crypto'); 
const bodyParser = require('body-parser');
  1. Look for app.use(express.static('public')); and add the following line below:

app.use(bodyParser.json());

  1. Create a post endpoint to receive the GitHub webhook:
const onWebhook = (req, res) => {
  let hmac = crypto.createHmac('sha1', process.env.SECRET);
  let sig  = `sha1=${hmac.update(JSON.stringify(req.body)).digest('hex')}`;

  if (req.headers['x-github-event'] === 'push' && sig === req.headers['x-hub-signature']) {
    cmd.run('chmod 777 ./git.sh'); 
    
    cmd.get('./git.sh', (err, data) => {  
      if (data) {
        console.log(data);
      }
      if (err) {
        console.log(err);
      }
    })

    cmd.run('refresh');
  }

  return res.sendStatus(200);
}

app.post('/git', onWebhook);
  1. Create a git.sh file adding the following lines:
#/bin/sh

# Fetch the newest code
git fetch origin master

# Hard reset
git reset --hard origin/master

# Force pull
git pull origin master --force

This file will be in charge of pulling the changes from your Github repo.

  1. Open the .env file and set a SECRET:
SECRET=cirrus-socrates-particle-decibel-hurricane-dolphin-tulip
  1. Open the glitch console for your project and generate a new SSH key with:
ssh-keygen

Just press <Enter> to accept all the questions.

  1. Read the content of the .ssh/id_rsa.pub file with:
cat .ssh/id_rsa.pub

Then copy the string to your clipboard.

  1. Create a new GitHub repo with a README.me file (or any other file, it's important that the project is not empty).
  2. Go to the deploy keys section of the settings page of your GitHub project.
  3. Click on Add deploy key and add the SSH key you generated in the step #8; add glitch.com in the title field.
  4. Check the Allow write access box too.
  5. Now open the webhooks section and add a new webhook (replacing PROJECT_NAME with your actual project name):
Payload URL: https://PROJECT_NAME.glitch.me/git
Content type: application/json
Secret: use the SECRET you set up in your glitch project

The rest of the defaults are OK.

  1. Go back to your Glitch project and export your project to GitHub (that will create a new glitch branch in your GitHub repo): Tools > Git, Import, and Export > Export to GitHub.

  2. In the Glitch console, set the remote origin to the master branch of your GitHub project:

git remote add origin [email protected]:USERNAME/PROJECT.git
git pull
git branch --set-upstream-to=origin/master master
  1. Clone your repo in your dev machine and merge the newly created glitch branch with the master branch:
git fetch
git merge master origin/glitch

Testing

  1. In your dev machine, create a dummy test file (like hello.txt) and commit it.
  2. Push the changes with git push.

If everything is OK, your Glitch project should be updated, and a hello.txt file should appear in the list of files.
If you don't see it, have a look to the log of your Glitch project.

Updating your project from GitHub β†’ Glitch

This should be the default method of updating your project. Develop in your dev machine, commit the changes and do a git push

Updating your project from Glitch β†’ GitHub

If you change something in Glitch, first you'll need to export your project to GitHub and then merge the glitch branch with your master branch.

git merge glitch
git push

Credits

While I've detailed all the steps and added information on how to add a deploy key, the overall solution (including the git.sh and webhook sync code) comes from this post by @jarvis394 on the glitch forum.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].