Push to GitHub

See deployments and automation for high-level information about how and when to the “Push to GitHub” publish action.

Overview

The “Push to GitHub” publish action can help you create a new Plasmic-powered app or update an existing one. To use the publish action, our Plasmic GitHub App must first request authorization for read and write access to your personal or organization’s repositories. The first time you publish your Plasmic project, Plasmic will add a GitHub Action to your repository that performs the automation.

You can always manage your authorized GitHub Apps in your GitHub settings.

Creating a new Plasmic repository

When creating a new Plasmic repository, the publish action can help you set up either a Headless API or Codegen project. After the action is completed, you should be left with a fully-functional Plasmic-powered app, as if you called plasmic init!

Configuration options:

  • Repository organization (or personal)
  • Repository name
  • Whether the repository is private
  • Framework (Next.js, Gatsby, or Plain React)
  • Language (JavaScript or TypeScript)
  • Mode (Headless API or Codegen)

Updating an existing Plasmic repository

For existing repositories, the publish action only works for Codegen projects. The publish action calls plasmic sync on the published project to re-generate the code for your Plasmic content. If any code changed, the publish action will either git push the code changes or submit a pull request for review.

Configuration options:

  • Repository
  • Branch to push changes to
  • Directory where build/sync commands should be run from
  • Default action (make pull request or commit changes)

Advanced

Customizing the GitHub push action

Now, you may want to customize the way this works. Examples of reasons:

  • You want to customize the commit messages.
  • You want to change the branch to something other than what you initially set when setting up the integration.
  • You want to run other build/deploy commands.

If you want to customize any aspect of this, you should detach the workflow. This means you now take ownership of the workflow instead of relying on the “Push to GitHub” mechanism.

Instead, you’ll be triggering the workflow via webhook— it will look no different than any other build+deploy webhook that you would otherwise configure.

In short, GitHub Actions can be triggered by a webhook. This is called repository_dispatch (there is also a workflow_dispatch alternative). The Plasmic workflow is already listening to repository_dispatch:

plasmic.yml
Copy
on:
repository_dispatch:
types: [plasmic]

Steps to trigger repository_dispatch

  1. Create a personal access token.
  2. Test that you can manually trigger the workflow using a repository_dispatch call, replacing the variables below and passing your personal access token:
    Copy
    curl \
    -i -u USER:TOKEN \
    -X POST \
    -H "Accept: application/vnd.github.v3+json" \
    https://api.github.com/repos/OWNER/REPO/dispatches \
    -d '{"event_type":"on-demand-test","client_payload":{"unit":false,"integration":true}}'
  3. Verify that an action run is happening.
  4. Open up the publish dialog in a Plasmic project.
  5. Add the above webhook as a publish action.
  6. Remove the “Push To GitHub” publish action.
  7. Finally, hit Publish to make sure it all works.

Hosting with GitHub Pages

The GitHub push action previously supported a feature for setting up GitHub Pages, but the feature stopped working in October 2022 because GitHub revoked access to an API the feature depended on for a security fix. If you want to continue using GitHub Pages, see the GitHub Pages page.

Was this page helpful?

Give feedback on this page