---
title: "Keeping your gists in sync with the source repository"
description: "Gists go stale the moment the source file moves on. A GitHub Action that re-uploads them on every release, so the shared copy never drifts."
canonical_url: "https://serhiichuk.dev/blog/keeping-your-gists-in-sync-with-the-source-repository/"
published: "2025-10-24T00:00:00.000Z"
tags:
  - "DevOps"
  - "GitHub Actions"
---

Often one may use GitHub Gists to share a piece of code or configuration which is a very handy way of content distribution. And it's very likely that the code or text you are sharing is coming from a repository.

The problem that sometimes occurs with such an approach is that repository code evolves and gists become unmaintainable. This is usually not intended when you share a gist directly and is even more problematic when a gist is used e.g. in an article like this one.

## Automating Gist updates with GitHub Actions

To solve the problem that may not have existed I created a GitHub action that updates gists for you whenever the source file of the repository changes. Welcome [gist-uploader-action](https://github.com/marketplace/actions/gist-uploader).

All you need is a [GitHub token](https://github.com/settings/tokens) with `gist` scope and a workflow with the Gist ID and the path to the file you're sharing:

```yaml
name: Update Gist

on:
  release:
    types:
      - published
  workflow_dispatch:

jobs:
  update-gist:
    runs-on: ubuntu-latest
    outputs:
      url: ${{ steps.gist.outputs.url }}
    steps:
      - uses: actions/checkout@v5

      - name: Update gist from file
        id: gist
        uses: xSAVIKx/gist-uploader-action@v0.1.3       # pin to a released version
        with:
          token: ${{ secrets.GIST_TOKEN }}
          gist_id: eeb24ff793d2d47b4f2f023ba554aee4     # ID of the target gist
          file_path: .github/workflows/update-gist.yml  # path in your repo to upload
          # Optional inputs:
          gist_description: "This gist is auto-updated using https://github.com/xSAVIKx/gist-uploader-action action"
          gist_file_name: "update-gist.yml" # defaults to the basename of file_path

      - name: Print gist URL
        run: |
          echo "Gist URL: ${{ steps.gist.outputs.url }}" >> $GITHUB_STEP_SUMMARY
```

_An example workflow that updates a Gist using GitHub Actions_

The workflow above uses the aforementioned [gist-uploader-action](https://github.com/xSAVIKx/gist-uploader-action) to automate the update of the gist with the workflow that automated the update of the gist 😃

I'm currently exploring other possible use cases for this action such as creating gists and keeping them up-to-date with externally-accessible files. Create an issue or reach out if that's something you may want to see in this action.
