Giter Site home page Giter Site logo

peaceiris / actions-gh-pages Goto Github PK

View Code? Open in Web Editor NEW
4.4K 27.0 349.0 7.82 MB

GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.

Home Page: https://github.com/marketplace/actions/github-pages-action

License: MIT License

Shell 3.38% TypeScript 95.15% JavaScript 0.59% CSS 0.08% HTML 0.81%
github-actions github-pages static-site-generator actions hugo gatsby mkdocs vuepress mdbook nextjs nuxt

actions-gh-pages's Introduction

GitHub Pages Action

GitHub Actions for deploying to GitHub Pages with Static Site Generators

license release GitHub release date Test Code Scanning CodeFactor

Note

See also the GitHub official GitHub Pages Action first.

This is a GitHub Action to deploy your static files to GitHub Pages. This deploy action can be combined simply and freely with Static Site Generators. (Hugo, MkDocs, Gatsby, mdBook, Next, Nuxt, and so on.)

The next example step will deploy ./public directory to the remote gh-pages branch.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

For newbies of GitHub Actions: Note that the GITHUB_TOKEN is NOT a personal access token. A GitHub Actions runner automatically creates a GITHUB_TOKEN secret to authenticate in your workflow. So, you can start to deploy immediately without any configuration.

Supported Tokens

Three tokens are supported.

Token Private repo Public repo Protocol Setup
github_token ✅️ ✅️ HTTPS Unnecessary
deploy_key ✅️ ✅️ SSH Necessary
personal_token ✅️ ✅️ HTTPS Necessary

Notes: Actually, the GITHUB_TOKEN works for deploying to GitHub Pages but it has still some limitations. For the first deployment, we need to select the gh-pages branch or another branch on the repository settings tab. See First Deployment with GITHUB_TOKEN

Supported Platforms

All Actions runners: Linux (Ubuntu), macOS, and Windows are supported.

runs-on github_token deploy_key personal_token
ubuntu-22.04 ✅️ ✅️ ✅️
ubuntu-20.04 ✅️ ✅️ ✅️
ubuntu-latest ✅️ ✅️ ✅️
macos-latest ✅️ ✅️ ✅️
windows-latest ✅️ (2) ✅️
  1. WIP, See Issue #87

GitHub Enterprise Server Support

✅️ GitHub Enterprise Server is supported above 2.22.6.

Note that the GITHUB_TOKEN that is created by the runner might not inherently have push/publish privileges on GHES. You might need to create/request a technical user with write permissions to your target repository.

Table of Contents

Getting started

Add your workflow file .github/workflows/gh-pages.yml and push it to your remote default branch.

Here is an example workflow for Hugo.

peaceiris/actions-hugo - GitHub

name: GitHub Pages

on:
  push:
    branches:
      - main  # Set a branch name to trigger deployment
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        # If you're changing the branch from main,
        # also change the `main` in `refs/heads/main`
        # below accordingly.
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public
Actions log overview GitHub Pages log

Options

⭐️ Set Runner's Access Token github_token

This option is for GITHUB_TOKEN, not a personal access token.

A GitHub Actions runner automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

For more details about GITHUB_TOKEN: Automatic token authentication - GitHub Docs

⭐️ Set SSH Private Key deploy_key

Read Create SSH Deploy Key, create your SSH deploy key, and set the deploy_key option like the following.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    publish_dir: ./public

⭐️ Set Personal Access Token personal_token

Generate a personal access token (repo) and add it to Secrets as PERSONAL_TOKEN, it works as well as ACTIONS_DEPLOY_KEY.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    personal_token: ${{ secrets.PERSONAL_TOKEN }}
    publish_dir: ./public

⭐️ Set Another GitHub Pages Branch publish_branch

Set a branch name to use as GitHub Pages branch. The default is gh-pages.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_branch: your-branch  # default: gh-pages

⭐️ Source Directory publish_dir

A source directory to deploy to GitHub Pages. The default is public. Only the contents of this dir are pushed to GitHub Pages branch, gh-pages by default.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./out  # default: public

⭐️ Deploy to Subdirectory destination_dir

This feature is on beta. Any feedback is welcome at Issue #324

A destination subdirectory on a publishing branch. The default is empty.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    destination_dir: subdir

⭐️ Filter publishing assets exclude_assets

This feature is on beta. Any feedback is welcome at Issue #163

Set files or directories to exclude from publishing assets. The default is .github. Values should be split with a comma.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    exclude_assets: '.github,exclude-file1,exclude-file2'

Set exclude_assets to empty for including the .github directory to deployment assets.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}   # Recommended for this usage
    # personal_token: ${{ secrets.PERSONAL_TOKEN }} # An alternative
    # github_token: ${{ secrets.GITHUB_TOKEN }}     # This does not work for this usage
    exclude_assets: ''

The exclude_assets option supports glob patterns.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    exclude_assets: '.github,exclude-file.txt,exclude-dir/**.txt'

⭐️ Add CNAME file cname

To add the CNAME file, we can set the cname option. Alternatively, put your CNAME file into your publish_dir. (e.g. public/CNAME)

For more details about the CNAME file, read the official documentation: Managing a custom domain for your GitHub Pages site - GitHub Docs

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    cname: github.com

⭐️ Enable Built-in Jekyll enable_jekyll

If you want GitHub Pages to process your site with the static site generator Jekyll, set enable_jekyll to true.

By default, this action signals to GitHub Pages that the site shall not be processed with Jekyll. This is done by adding an empty .nojekyll file on your publishing branch. When that file already exists, this action does nothing.

Bypassing Jekyll makes the deployment faster and is necessary if you are deploying files or directories that start with underscores, since Jekyll considers these to be special resources and does not copy them to the final site. You only need to set enable_jekyll to true when you want to deploy a Jekyll-powered website and let GitHub Pages do the Jekyll processing.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    enable_jekyll: true

For more details about .nojekyll: Bypassing Jekyll on GitHub Pages - The GitHub Blog

⭐️ Allow empty commits allow_empty_commit

By default, a commit will not be generated when no file changes. If you want to allow an empty commit, set the optional parameter allow_empty_commit to true.

For example:

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    allow_empty_commit: true

⭐️ Keeping existing files keep_files

By default, existing files in the publish branch (or only in destination_dir if given) will be removed. If you want the action to add new files but leave existing ones untouched, set the optional parameter keep_files to true.

Note that users who are using a Static Site Generator do not need this option in most cases. Please reconsider your project structure and building scripts, or use a built-in feature of a Static Site Generator before you enable this flag.

For example:

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    keep_files: true

With the v3, this option does not support working with the force_orphan option. The next major release (version 4) will support this. See the issue #455

⭐️ Deploy to external repository external_repository

By default, your files are published to the repository which is running this action. If you want to publish to another repository on GitHub, set the environment variable external_repository to <username>/<external-repository>.

For example:

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    external_repository: username/external-repository
    publish_branch: your-branch  # default: gh-pages
    publish_dir: ./public

You can use deploy_key or personal_token. When you use deploy_key, set your private key to the repository which includes this action and set your public key to your external repository.

Note that GITHUB_TOKEN has no permission to access to external repositories. Please create a personal access token and set it to personal_token like personal_token: ${{ secrets.PERSONAL_TOKEN }}.

Use case:

A GitHub Free Plan account cannot use the GitHub Pages in a private repository. To make your source contents private and deploy it with the GitHub Pages, you can deploy your site from a private repository to a public repository using this option.

  • peaceiris/homepage: A private repository running this action with external_repository: peaceiris/peaceiris.github.io
  • peaceiris/peaceiris.github.io: A public repository using GitHub Pages

⭐️ Force orphan force_orphan

We can set the force_orphan: true option. This allows you to make your publish branch with only the latest commit.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    force_orphan: true

⭐️ Set Git username and email

Set custom git config user.name and git config user.email. A commit is always created with the same user.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    user_name: 'github-actions[bot]'
    user_email: 'github-actions[bot]@users.noreply.github.com'

Add GitHub Actions bot as a committer

⭐️ Set custom commit message

Set a custom commit message. When we create a commit with a message docs: Update some post, a deployment commit will be generated with a message docs: Update some post ${GITHUB_SHA}.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    commit_message: ${{ github.event.head_commit.message }}

Set a custom commit message - GitHub Actions for GitHub Pages

To set a full custom commit message without a triggered commit hash, use the full_commit_message option instead of the commit_message option.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
    full_commit_message: ${{ github.event.head_commit.message }}

⭐️ Create Git tag

Here is an example workflow.

name: GitHub Pages

on:
  push:
    branches:
      - main
    tags:
      - 'v*.*.*'

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Some build

      - name: Prepare tag
        id: prepare_tag
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          echo "DEPLOY_TAG_NAME=deploy-${TAG_NAME}" >> "${GITHUB_OUTPUT}"

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public
          tag_name: ${{ steps.prepare_tag.outputs.DEPLOY_TAG_NAME }}
          tag_message: 'Deployment ${{ github.ref_name }}'

Commands on a local machine.

$ # On a main branch
$ git tag -a "v1.2.3" -m "Release v1.2.3"
$ git push origin "v1.2.3"

$ # After deployment
$ git fetch origin
$ git tag
deploy-v1.2.3  # Tag on the gh-pages branch
v1.2.3         # Tag on the main branch

Tips and FAQ

⭐️ Create SSH Deploy Key

Generate your deploy key with the following command.

ssh-keygen -t rsa -b 4096 -C "$(git config user.email)" -f gh-pages -N ""

You will get 2 files:

  • gh-pages.pub is a public key
  • gh-pages is a private key

Next, Go to Repository Settings

  • Go to Deploy Keys and add your public key with the Allow write access
  • Go to Secrets and add your private key as ACTIONS_DEPLOY_KEY
Add your public key Success
Add your private key Success

⭐️ First Deployment with GITHUB_TOKEN

The GITHUB_TOKEN has limitations for the first deployment so we have to select the GitHub Pages branch on the repository settings tab. After that, do the second deployment like the following pictures.

First deployment failed Go to the settings tab
Select branch Deploying again and succeed

If the action fails to push the commit or tag with the following error:

/usr/bin/git push origin gh-pages
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/username/repository.git/': The requested URL returned error: 403
Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"

Please add the write permission to the permissions.contents in a workflow/job.

permissions:
  contents: write

Alternatively, you can configure the default GITHUB_TOKEN permissions by selecting read and write permissions.

⭐️ Use the latest and specific release

We recommend you to use the latest and specific release of this action for stable CI/CD. It is useful to watch this repository (release only) to check the latest release of this action.

For continuous updating, we can use the GitHub native Dependabot. Here is an example configuration of the bot. The config file is located in .github/dependabot.yml.

version: 2
updates:
- package-ecosystem: "github-actions"
  directory: "/"
  schedule:
    interval: "daily"
  labels:
  - "CI/CD"
  commit-message:
    prefix: ci

See the official documentation for more details about the Dependabot: Keeping your dependencies updated automatically - GitHub Docs

⭐️ Schedule and Manual Deployment

For deploying regularly, we can set the on.schedule workflow trigger. See Scheduled events | Events that trigger workflows - GitHub Docs

For deploying manually, we can set the on.workflow_dispatch workflow trigger. See Manual events workflow_dispatch | Events that trigger workflows - GitHub Docs

name: GitHub Pages

on:
  push:
    branches:
      - main
  schedule:
    - cron: "22 22 * * *"
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
    ...

⭐️ Release Strategy

cf. support: execution from hashref disabled/broken vs GitHub Actions Security Best Practice? · Issue #712 · peaceiris/actions-gh-pages

Our project builds and provides build assets only when creating a release. This is to prevent the user from executing this action with a specific branch (like main). For example, if we maintain build assets in the main branch and users use this action as follows, a major release including breaking changes will break the CI workflow of the users silently.

- uses: peaceiris/actions-gh-pages@main # Bad example!
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

In this project, a major tag (e.g. v3) is guaranteed to contain no breaking changes. But, we recommend using a tag or a commit hash for the stability of your workflows.

- uses: peaceiris/[email protected] # tag: Better
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public
- uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # commit hash of v3.9.3: Best!
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

For verifying the release asset, we can use the following commands.

git clone https://github.com/peaceiris/actions-gh-pages.git
cd ./actions-gh-pages
git checkout v3.9.3
nvm install
nvm use
npm i -g npm
npm ci
npm run build
git diff ./lib/index.js # We will get zero exit code

Examples

⭐️ Static Site Generators with Node.js

hexo, vuepress, react-static, gridsome, create-react-app and so on. Please check where your output directory is before pushing your workflow. e.g. create-react-app requires publish_dir to be set to ./build

Premise: Dependencies are managed by package.json and package-lock.json

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm ci
      - run: npm run build

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

⭐️ Gatsby

An example for Gatsby (Gatsby.js) project with gatsby-starter-blog

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm ci
      - run: npm run format
      - run: npm run test
      - run: npm run build

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

⭐️ React and Next

An example for Next.js (React.js) project with create-next-app

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Get yarn cache
        id: yarn-cache
        run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      - run: yarn install --frozen-lockfile
      - run: yarn build
      - run: yarn export

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./out

⭐️ Vue and Nuxt

An example for Nuxt.js (Vue.js) project with create-nuxt-app

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm ci
      - run: npm test
      - run: npm run generate

      - name: deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist

⭐️ Docusaurus

An example workflow for Docusaurus.

npx @docusaurus/init@next init website classic is useful to create a new Docusaurus project.

# .github/workflows/deploy.yml

name: GitHub Pages

on:
  push:
    branches:
      - main
    paths:
      - '.github/workflows/deploy.yml'
      - 'website/**'
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    defaults:
      run:
        working-directory: website
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Get yarn cache
        id: yarn-cache
        run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
          key: ${{ runner.os }}-website-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-website-

      - run: yarn install --frozen-lockfile
      - run: yarn build

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./website/build

⭐️ Static Site Generators with Python

pelican, MkDocs, sphinx, and so on.

Premise: Dependencies are managed by requirements.txt

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Python
        uses: actions/setup-python@v3
        with:
          python-version: '3.8'

      - name: Upgrade pip
        run: |
          # install pip=>20.1 to use "pip cache dir"
          python3 -m pip install --upgrade pip

      - name: Get pip cache dir
        id: pip-cache
        run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Install dependencies
        run: python3 -m pip install -r ./requirements.txt

      - run: mkdocs build

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./site

⭐️ mdBook (Rust)

An example GitHub Actions workflow to deploy rust-lang/mdBook site to GitHub Pages.

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup mdBook
        uses: peaceiris/actions-mdbook@v1
        with:
          mdbook-version: '0.4.8'
          # mdbook-version: 'latest'

      - run: mdbook build

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./book

Hint: you may want to publish your rustdocs. And use relative links to it from the md docs, and have them checked by mdbook. Then, according to the doc, you may put ./target/doc/ to your ./book/src dir before you mdbook build and then it will end up in ./book/html/ and in your Github Pages.

⭐️ Flutter Web

An example workflow for Flutter web project.

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Flutter
        run: |
          git clone https://github.com/flutter/flutter.git --depth 1 -b beta _flutter
          echo "${GITHUB_WORKSPACE}/_flutter/bin" >> ${GITHUB_PATH}

      - name: Install
        run: |
          flutter config --enable-web
          flutter pub get

      - name: Build
        run: flutter build web

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./build/web

⭐️ Elm

An example workflow for Elm.

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'

      - name: Setup Elm
        run: npm install elm --global

      - name: Make
        run: elm make --optimize src/Main.elm

      - name: Move files
        run: |
          mkdir ./public
          mv ./index.html ./public/
        # If you have non-minimal setup with some assets and separate html/js files,
        # provide --output=<output-file> option for `elm make` and remove this step

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

⭐️ Swift Publish

An example workflow for JohnSundell/Publish.

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: macos-latest
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3

      - uses: actions/cache@v3
        with:
          path: |
            ~/Publish_build
            .build
          key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
          restore-keys: |
            ${{ runner.os }}-spm-

      - name: Setup JohnSundell/Publish
        run: |
          cd ${HOME}
          export PUBLISH_VERSION="0.7.0"
          git clone https://github.com/JohnSundell/Publish.git
          cd ./Publish && git checkout ${PUBLISH_VERSION}
          mv ~/Publish_build .build || true
          swift build -c release
          cp -r .build ~/Publish_build || true
          echo "${HOME}/Publish/.build/release" >> ${GITHUB_PATH}

      - run: publish-cli generate

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v4
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./Output

License

Maintainer

actions-gh-pages's People

Contributors

cito avatar corollari avatar deimosfr avatar deining avatar dependabot-preview[bot] avatar dependabot[bot] avatar elsatch avatar imgbot[bot] avatar imomaliev avatar indyjonesnl avatar kingofzeal avatar lete114 avatar mambax avatar mhucka avatar mikaelsmith avatar nikos912000 avatar oprypin avatar peaceiris avatar renovate[bot] avatar romanhotsiy avatar sarisia avatar sasoria avatar spicyricecaker avatar sukkaw avatar ta1m1kam avatar tanducmai avatar thundermiracle avatar tripleight avatar wilfred avatar zhouzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actions-gh-pages's Issues

proposal: tag the latest release with major version

Is your feature request related to a problem? Please describe.
Could you please tag the latest release with major version (v2 here) ?
With major version tag we can always use the latest action without breaking changes and can specify this action as described in the official document:

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses

Describe the solution you'd like
Tag the latest release with v2 tag

Bug: forceOrphan isn't working with actions-gh-pages@v3

Describe the bug
forceOrphan isn't working with actions-gh-pages@v3. The older version @v2 is working fine with that parameter.

To Reproduce

I'm using the following "Deploy":

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./public
          forceOrphan: true

But after that I can see additional commit in my gh-pages branch (https://github.com/ruzickap/action-test/commits/gh-pages).

Expected behavior
I hope this will work the same like in version @v2

Your YAML file

Additional context

Logs:

/bin/chmod 600 /home/runner/.ssh/known_hosts
[INFO] wrote /home/runner/.ssh/github
/bin/chmod 600 /home/runner/.ssh/github
[INFO] wrote /home/runner/.ssh/config
/bin/chmod 600 /home/runner/.ssh/config
/usr/bin/ssh-add /home/runner/.ssh/github
Identity added: /home/runner/.ssh/github ([email protected])
[INFO] remoteURL: [email protected]:ruzickap/action-test.git
[INFO] ForceOrphan: false
/usr/bin/git clone --depth=1 --single-branch --branch gh-pages [email protected]:ruzickap/action-test.git /home/runner/actions_github_pages
Cloning into '/home/runner/actions_github_pages'...
Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
/usr/bin/git rm -r --ignore-unmatch *
rm 'CNAME'
rm 'index.html'
[INFO] copy /home/runner/work/action-test/action-test/public/CNAME
[INFO] copy /home/runner/work/action-test/action-test/public/index.html
/usr/bin/git remote rm origin
/usr/bin/git remote add origin [email protected]:ruzickap/action-test.git
/usr/bin/git add --all
/usr/bin/git commit -m deploy: 1f265a6f07dd5cf3ddddb48caf28d28a5a597de8
[gh-pages d18ee8b] deploy: 1f265a6f07dd5cf3ddddb48caf28d28a5a597de8
 2 files changed, 2 insertions(+), 2 deletions(-)
/usr/bin/git push origin gh-pages
To github.com:ruzickap/action-test.git
   e122b2f..d18ee8b  gh-pages -> gh-pages
[INFO] successfully deployed

Enhancement: Deploy to other repo

Hello @peaceiris , thank you for developing this GitHub Action!

Here's my enhancement suggestion: I want to be able to deploy the build artifact from repo A to the GitHub Pages branch of repo B.

Use case: If you develop a website in a private GitHub repo that you want to deploy to your user github page (<username>.github.io) you have to deploy from repo A to repo B.

Suggestion: Replace GITHUB_REPOSITORY with a custom configurable variable.

Bug: Successfully pushes to branch only if it does not exist

Describe the bug
Successfully pushes to branch only if it does not exist yet

To Reproduce
Steps to reproduce the behavior:

  1. create repo
  2. deploy to somebranch first time (success)
  3. deploy to somebranch second time (pipeline succeeds, but does not actually push)
  4. delete somebranch
  5. deploy to somebranch third time (success)

Expected behavior
Always push

Your YAML file
https://github.com/VladimirLogachev/vladimirlogachev.github.io

name: Deploy to GitHub Pages
on:
  push:
    branches:
    - dev

jobs:
  build:
    name: Build elm
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set up elm
        uses: justgook/setup-elm@v1
      - name: Elm Make
        run: elm make src/Main.elm
      - name: Remove sources
        run: |
          rm -rf src
          rm -rf elm-stuff
          rm -rf .github
          rm -f .gitignore
          rm -f README.md
          rm -f elm.json
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v2
        env:
          ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          PUBLISH_BRANCH: somebranch
          PUBLISH_DIR: .
        with:
          emptyCommits: false

Update: readme

I found it. The following step will work well for only private repo. And there is no docker build step, it completes fast.

    - name: Deploy
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        PUBLISH_BRANCH: gh-pages # or master
        PUBLISH_DIR: ./public
      run: |
        wget https://raw.githubusercontent.com/peaceiris/actions-gh-pages/v2.4.0/entrypoint.sh
        bash ./entrypoint.sh

For private repositories, the above approach works well but public repositories failed.

    - name: Deploy
      uses: peaceiris/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        PUBLISH_BRANCH: gh-pages
        PUBLISH_DIR: ./public

The above (use action) also works well for only private repo.

Originally posted by @peaceiris in #9 (comment)


  • change: ssh key path for script mode.
  • docs: Add new section script mode
  • docs: Add GITHUB_TOKEN for only private repo.

Support /docs option with deployments

Is your feature request related to a problem? Please describe.

I would like to deploy to /docs instead of the master or gh-pages branch.

Describe the solution you'd like

Both the source and github pages are located in the master branch:

./src => source of the website
./docs => publish gh-pages website

I would like the files to be deployed to the ./docs folder

Describe alternatives you've considered

I've checked whether gh-pages was possible, but I can't find the option in my gh-pages repository:

image

Additional context
Add any other context or screenshots about the feature request here.

proposal: Migrate to TypeScript action

Is your feature request related to a problem? Please describe.
As a v3.

Describe the solution you'd like
Migrate to a TypeScript action as I did for peaceiris/actions-hugo.

Describe alternatives you've considered
none.

Additional context

  • Add supporting for macOS and Windows.
  • Add test deploy workflow to gh-pages branch on this repo.
    • Publish document site of this action with mdBook.
  • v3 stable tag
    • Add auto update workflow
  • v2
    • Add log output of v3 announcement

proposal: Create Tag on Commit

Is your feature request related to a problem? Please describe.
I'd like to tag specific versions of my gh-pages branch programmatically (in my case, based on package.json version)

Describe the solution you'd like
I'd like an option to add a tag with a specified name on commit.

Describe alternatives you've considered
Manually - PITA.

Additional context
I'm thinking I'd like to be able to use this like so:

- name: Tagged Deploy
  env:
    ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    PUBLISH_BRANCH: gh-pages
    PUBLISH_DIR: ./public
    CREATE_TAG: ${{ <expression> }}

Where expression might load some values from other steps or combine readily available job information.

Other options for forcing the overwrite of an existing tag or not might make sense too.

Bug: Run failed. [error]File not found

Describe the bug

Run failed with peaceiris/actions-gh-pages@v3

To Reproduce

my yml file:

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.PERSONAL_TOKEN }}
          publish_branch: gh-pages
          publish_dir: ./book
          force_orphan: true

error:

Run peaceiris/actions-gh-pages@v3
  with:
    personal_token: ***
    publish_branch: gh-pages
    publish_dir: ./book
    force_orphan: true
    allow_empty_commit: false
    keep_files: false
##[error]File not found: '/home/runner/work/_actions/peaceiris/actions-gh-pages/v3/lib/index.js'

Screenshots
image

INPUT_EMPTYCOMMITS is not defined with a docker image from Docker Hub

I will fix this by #28

And I found it that inputs were not defined when we use a docker image from Docker Hub without with statement even though we defined emptyCommits default true

I will ask about this behavior at the GitHub Community forum.

INPUT_EMPTYCOMMITS were not defined

    - name: Deploy
      uses: docker://peaceiris/gh-pages:v2.3.1
      env:
        PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
        PUBLISH_BRANCH: gh-pages
        PUBLISH_DIR: ./public
-e PERSONAL_TOKEN -e PUBLISH_BRANCH -e PUBLISH_DIR -e HOME

INPUT_EMPTYCOMMITS were defined

    - name: Deploy
      uses: docker://peaceiris/gh-pages:v2.3.1
      env:
        PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
        PUBLISH_BRANCH: gh-pages
        PUBLISH_DIR: ./public
      with:
        emptyCommits: true
        # emptyCommits: false
-e PERSONAL_TOKEN -e PUBLISH_BRANCH -e PUBLISH_DIR -e INPUT_EMPTYCOMMITS -e HOME

Originally posted by @peaceiris in #27 (comment)

Deployment to git repository works but website is not deployed

I have a strange behavior here, which is not strictly related to this action but kinds of defeat its purpose.

Here is a quite trivial repository showing this problem: https://github.com/nicolas-van/hugotest (the attached workflow: https://github.com/nicolas-van/hugotest/blob/master/.github/workflows/hugo.yml )

When I commit something the workflow performs correctly ( https://github.com/nicolas-van/hugotest/actions ) and I can validate it did deploy correctly to the gh-pages branch.

But when I take a look at the deployments ( https://github.com/nicolas-van/hugotest/deployments ) I can see that Github just didn't care re-deploying my website to its static content server. He doesn't seem to understand that there is a new version on the gh-pages branch and doesn't care re-deploying.

I suppose it has something to do with the fact that this action just erase all the commits on the gh-pages branch and make a force push. When I edit a file on that branch (thus creating a new commit) Github seems to detect it correctly and re-deploy my Github Pages site.

Does anyone else has encountered that problem ? If I'm not the only one maybe we could consider adding a mode similar to what Travis uses ( See keep_history https://docs.travis-ci.com/user/deployment/pages/).

"can't create '/github/home/ghpages_30566/.git': File exists"

Hello,
I am trying to build my Hugo website with peaceiris/actions-hugo and deploy with actions-gh-pages to the master branch of my GitHub pages repository.

It fails on the Deploy job where actions-gh-pages is used with the following error:

cp: can't create '/github/home/ghpages_30566/.git': File exists
##[error]Docker run failed with exit code 123

Can it be because of the fact that ./public (my PUBLISH_DIR) is actually a submodule with GitHub pages repo? I used it to quickly build and deploy locally.

Thank you.

cp: can't create '/.git': File exists | Error on user type repository deployment

Hello I found a recurring error when I try to deploy to my user type repository.

Stack trace:

/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/blog/blog":"/github/workspace" fbc64f:bd4f8c40a2ff4d509a3eda2d208b73d4
INFO: Deploy to asurbernardo/asurbernardo.github.io
INFO: setup with ACTIONS_DEPLOY_KEY
# github.com:22 SSH-2.0-babeld-85ff8279
Cloning into '/github/home/ghpages_12475'...
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
rm '404.html'
rm 'CNAME'
rm 'README.md'
rm 'commento.html'
rm 'images/design-inspiration.jpg'
rm 'index.html'
rm 'index.xml'
rm 'install-sw.html'
rm 'manifest.json'
rm 'offline.html'
rm 'posts/el-primer-post-en-mi-nuevo-blog/index.html'
rm 'posts/index.html'
rm 'posts/index.xml'
rm 'posts/la-primera-iteracion-amp-estilos-y-miscelanea/index.html'
rm 'posts/mi-primer-post/index.html'
rm 'sitemap.xml'
rm 'sw.js'
rm 'tags/deploy/index.html'
rm 'tags/deploy/index.xml'
rm 'tags/evolutivo/index.html'
rm 'tags/evolutivo/index.xml'
rm 'tags/git/index.html'
rm 'tags/git/index.xml'
rm 'tags/index.html'
rm 'tags/index.xml'
rm 'tags/iteracion/index.html'
rm 'tags/iteracion/index.xml'
rm 'tags/iteración/index.html'
rm 'tags/iteración/index.xml'
cp: can't create '/github/home/ghpages_12475/.git': File exists
##[error]Docker run failed with exit code 123

My action main.yml:

name: Deploy blog
on:
  push:
    branches:
    - master

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    steps:

    - name: Pull source
      uses: actions/checkout@master
      with:
        submodules: true

    - name: Update submodules to latests master
      run: git submodule update --remote

    - name: Setup Hugo
      uses: peaceiris/[email protected]
      with:
        hugo-version: '0.58.3'
        extended: true

    - name: Build
      run: hugo -t amperage --gc --minify

    - name: Deploy script
      uses: peaceiris/[email protected]
      env:
        ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        EXTERNAL_REPOSITORY: asurbernardo/asurbernardo.github.io
        PUBLISH_BRANCH: master
        PUBLISH_DIR: ./public

I think I've followed the guide correctly, but maybe I'm missing something.

Custom domain support

The current version of the action seems like it doesn't support custom domain. It would be great if we could set the CNAME via the deploy command.

How to deploy to 'protected branches' with this tool?

Is your feature request related to a problem? Please describe.
It is frustrating that you use a CI/CD tool like this to automate the process and make deploying code easier, but at the same time you require there to be no branch protection on this branch (IE it is still possible to deploy without checks from localhost).

Describe the solution you'd like
An explination of how to avoid this issue, or a clear solution.

Describe alternatives you've considered
I have considered making another GH user account and adding it to my organization as a "machine" user, this user could then have push permission on the protected branch. But this will use an extra slot for our GH payed account. Please advise.

Additional context
This is the exact error I get:
`
remote: error: GH006: Protected branch update failed for refs/heads/gh-pages.
remote: error: At least 1 approving review is required by reviewers with write access.
To github.com:wild-cards/ui.git
``

proposal: Allow option to mirror current commit message on external repo commit message

When using EXTERNAL_REPOSITORY, the only option for the commit message is currently

COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"

It would be awesome if we could have the option to have the message of the commit we're currently deploying as the commit message for the external repo, in order to see on the external repo what we've just deployed, instead of the current generic message.

Proposal: Add option to define custom Git user.name and user.email

Describe the bug
I want to change the user.name and user.email, such as 'test-user' and '[email protected]' for deploy commits.

Expected behavior
Assume this is the commit list:

Commits on Dec 24, 2019
  chore: deploy to gh-pages      
  `orzyyyy` committed 17 minutes ago
      |
      ---------------------->   this one is not the expected user

Commits on Dec 24, 2019
  chore: deploy to gh-pages                        
    `test-user` committed 17 minutes ago
      |
      ---------------------->   this one is expected

Your YAML file

name: deploy

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: set username and email
        run: |
          git config --global user.name "test-user"
          git config --global user.email [email protected]

      - name: checkout
        uses: actions/checkout@master

      - name: install
        run: npm install

      - name: build
        run: npm run build

      - name: debug
        run: git config --list

      - name: deploy
        uses: peaceiris/actions-gh-pages@v2
        env:
          ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          PUBLISH_BRANCH: gh-pages
          PUBLISH_DIR: ./dist
        with:
          emptyCommits: false

Prevent empty commits happen

Is your feature request related to a problem? Please describe.
Sometimes I add commits to master which don't change gh-pages output. Empty commits add to gh-pages in such case.

Example of such commits: experiment with github actions, re-run github actions, add drafts content etc.

Describe the solution you'd like
No add empty commits to gh-pages. Just do nothing then.

I generate gh-pages using peaceiris/[email protected].

What am I doing wrong?

Hello,

In my case I am added as a collaborator (full admin access) to an Organization. I am trying to setup a simple static site push to gh-pages. I have setup using ACTIONS_DEPLOY_KEY. The deploy succeeds but the site changes are not reflected. In-fact if I manually delete gh-pages branch and re-run the action, it succeeds again, but the site is never published. All the code seems okay in gh-pages. What am I doing wrong? here' s my action yaml

name: Publish Site

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Master Branch
        uses: actions/checkout@v1

      - name: Build
        run: |
          rm -rf dist
          rsync -rv --exclude=.git --exclude=.github . dist

      - name: Deploy to gh-pages
        uses: peaceiris/[email protected]
        env:
          ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          PUBLISH_BRANCH: gh-pages
          PUBLISH_DIR: ./dist

Originally posted by @shaunakv1 in #9 (comment)

fatal: Could not read from remote repository.

Describe the bug
I got this problem while deploying Gatsbyjs project to github pages.

Load key "/root/.ssh/id_rsa": invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
##[error]Docker run failed with exit code 128

To Reproduce
Here's How I created the .yml file

name: github pages

on:
  push:
    branches:
    - master

jobs:
  build-deploy:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v1

    - name: Setup Node
      uses: actions/setup-node@v1
      with:
        node-version: '10.x'

    - name: Cache dependencies
      uses: actions/cache@v1
      with:
        path: ~/.npm
        key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
        restore-keys: |
          ${{ runner.os }}-node-
    - run: yarn
    - run: git config --global user.email "[email protected]"
    - run: git config --global user.name "Zeyad Etman"
    
    - run: yarn build

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v2
      env:
        ACTIONS_DEPLOY_KEY: ${{ secrets.GITHUB_API_DEPLOY }}
        PERSONAL_TOKEN: ${{ secrets.GITHUB_API_DEPLOY }}
        PUBLISH_BRANCH: gh-pages
        PUBLISH_DIR: ./public

Expected behavior
It deploys successfully.

Additional context
I'm building with yarn.

Option to not have empty commits

Love the work on this. One question for an enhancement:

I'm curious if a option can be added to either opt in (or opt out, either way) of creating empty commits when publishing.

Basically, I would rather my publish branch (gh_pages) only reflect changes to my site when things actually change. This is especially noticeable as I'm building up my workflow, which is understandably an incremental process.

It looks like the fix would be pretty straightforward here (removing the --allow-empty flag), but I also understand that some may want this behavior, and I'm unsure how to make it something optional.

I can look into it when I have some time, but I probably won't get to it very quickly, so wanted to throw it out to see if someone might be able to pick it up before I can.

Adding peaceiris/actions-gh-pages@v2 to action with PUBLISH_BRANCH: master and PUBLISH_DIR: . causes it to self-delete each time it runs

Adding

   - name: Deploy	
      uses: peaceiris/actions-gh-pages@v2	
      env:	
        ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}	
        #PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}	
        #GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}	
        PUBLISH_BRANCH: master	
        PUBLISH_DIR: .

to the end of a workflow causes it to delete the workflow file from github each time it runs:
broadinstitute/omim-search@b83f911
Example run logs are here:
https://github.com/macarthur-lab/omim-search/runs/366450678

docs: Update Hugo example

  • Update Hugo workflow example (Install Hugo with downloading binary)
  • Remove peaceiris/actions-hugo from README

Parameter for keeping only last commit in `gh-pages`

Hello.

Would it be possible to implement some parameter which will keep only the last commit for the gh-pages containing generated HTML files?

-> I do not want to keep the "standard" commit history for HTML pages (gh-pages) - therefore some parameter which will keep only the last commit (with last HTML pages) may be handy.

Use docker image from GitHub Package Registry

2019-09-02: We cannot pull docker images from GitHub Package Registry.
cf. Workflow syntax for GitHub Actions - GitHub Help

I asked about this at Use docker images from GitHub Package Registry - GitHub Community Forum

.github/workflows/docker-image-ci.yml

on:
  release:
    types: [published, created]

    - name: push latest image
      env:
        DOCKER_IMAGE: docker.pkg.github.com/${{ github.repository }}/action:latest
        PKG_GITHUB_TOKEN: ${{ secrets.PKG_GITHUB_TOKEN }}
      run: |
        echo ${PKG_GITHUB_TOKEN} | docker login docker.pkg.github.com -u peaceiris --password-stdin
        docker push ${DOCKER_IMAGE} &&
        docker logout

proposal: keep_history option

Is your feature request related to a problem? Please describe.
I'm migrating my pages from travis which provides a keep_history option. If set to false, the building process will only preserve the last commit to the target branch. So I would love to have a similar option here.

Describe the solution you'd like
A keep_history option, default to true.

Describe alternatives you've considered
A remove_history option, default to false.

Additional context
N/A

Action passed with silent failure when no gh-pages branch existed

Thanks for publishing this action.

I followed the readme instructions but ran into what may be a common but undocumented case.

I'm publishing for the first time and no gh-pages branch exists.

The action proceeds to stage changes but they never get pushed to my PUBLISH_BRANCH

Cloning into '/github/home/b8c542550a778e3eb0ca70abff3d5482'...
warning: Could not find remote branch gh-pages to clone.
fatal: Remote branch gh-pages not found in upstream origin
Initialized empty Git repository in /github/workspace/target/doc/.git/
Switched to a new branch 'gh-pages'
fatal: No such remote: 'origin'
INFO: Allowing empty commits: 
[gh-pages (root-commit) 975a973] Automated deployment: Sun Sep 22 04:26:54 UTC 2019 3a9dc85d243d35fe33b4992ae2a042c6793e8861
 131 files changed, 15230 insertions(+)
 create mode 100755 .lock
...more files...

My workflow step is configured with

- name: Publish
        uses: docker://peaceiris/gh-pages:v2.3.1
        env:
          PUBLISH_BRANCH: gh-pages
          PUBLISH_DIR: ./target/doc
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Update mkdocs example

If I understood correctly, the mkdocs example uses the retired actions-pipenv. It this statement holds, it might be worth updateing the example to a supported architecture

proposal: Add support issue template

Is your feature request related to a problem? Please describe.
Help and support users.

Describe the solution you'd like
Add a new issue template for supporting.

Describe alternatives you've considered
N/A

Additional context

  • Add a new workflow to close invalid issues automatically.
    • Ignore template
    • Unrelated to this repo
  • Add a new stale workflow to close old issues automatically.
  • Update FAQs.

Unable to deploy static hugo page due to auth issue

Hi! I just setup a new hugo site with the intent to publish to the gh-pages branch of the same repo in the root directory (i.e., .).

The workflow looks like this:

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master

      - name: build
        uses: peaceiris/[email protected]
        with:
          args: --gc --minify --cleanDestinationDir

      - name: deploy
        uses: peaceiris/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PUBLISH_BRANCH: gh-pages
          PUBLISH_DIR: .

It fails on the deploy step with this:

/usr/bin/docker run --name b6eba6be5b8977615c40ca9a20a95bc21bdd74_f636c9 --label b6eba6 --workdir /github/workspace --rm -e GITHUB_TOKEN -e PUBLISH_BRANCH -e PUBLISH_DIR -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/p17/p17":"/github/workspace" b6eba6:be5b8977615c40ca9a20a95bc21bdd74
Reinitialized existing Git repository in /github/workspace/.git/
fatal: remote origin already exists.
Switched to a new branch 'gh-pages'
Branch 'gh-pages' set up to track remote branch 'gh-pages' from 'origin'.
[gh-pages 314b0a0] Automated deployment: Thu Sep  5 06:20:36 UTC 2019 466fd027c30da77da2cd2c1dfbf47912ce4c1f15
 4 files changed, 4 insertions(+)
 create mode 100644 public/categories/index.xml
 create mode 100644 public/index.xml
 create mode 100644 public/sitemap.xml
 create mode 100644 public/tags/index.xml
 fatal: could not read Username for 'https://github.com': No such device or address
##[error]Docker run failed with exit code 128

Any ideas on what I'm doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.