Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide starter workflows to Custom GitHub Actions Workflows in GitHub Pages #2561

Open
tnir opened this issue Jul 28, 2022 · 6 comments
Open
Labels

Comments

@tnir
Copy link
Contributor

tnir commented Jul 28, 2022

Custom GitHub Actions Workflows were just announced.

As of the announcement, Next.js, Hugo, Gatsby, Jekyll, and NuxtJS are the first starter workflows available at https://github.com/actions/starter-workflows/tree/main/pages.

https://github.blog/changelog/2022-07-27-github-pages-custom-github-actions-workflows-beta/

I would be happy if custom GitHub Actions workflow for Middleman is provided in that repository, somewhere else (or this repository).

@tdreyno
Copy link
Member

tdreyno commented Jul 28, 2022

Interesting. I don't have time to investigate right now, but PRs are welcome

@joapuiib
Copy link

I have this workflow, which builds the site in the master branch and deploys it to the gh-pages branch.
It also has a cache for the gems installed with bundler, to reduce the build time.
It has the installation of NPM commented, in case you need it.

name: Middleman deploy on push
on:
  push:
    branches:
      - master
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout repo
        uses: actions/checkout@master
        with:
          submodules: true
          token: ${{ secrets.ACCESS_TOKEN }}
      - name: Setup Ruby
        uses: actions/setup-ruby@v1
        with:
          ruby-version: '2.7'
      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - name: Install bundler
        run: gem install bundler:2.1.4
      - name: Bundle install
        run: |
            bundle config path vendor/bundle
            bundle install --jobs 4 --retry 3
      # - name: npm install packages
      #   run: |
      #       npm install
      - name: Build site
        run: bundle exec middleman build
      - name: Deploy site
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          FOLDER: build

I don't know if this is what you are looking for, but I hope it helps you.
Remember to change the versions to fit your needs.

@tnir
Copy link
Contributor Author

tnir commented Aug 29, 2022

@joapuiib Thanks, but your suggestion is the legacy one suitable before Custom GitHub Actions Workflows (beta). You do not have to use an extra branch like gh-pages any more. We already do it in a new workflow for a month. What I need to do is to push my work to this repo or the upstream i.e., actions/starter-workflows.

@markets
Copy link
Member

markets commented Sep 13, 2022

What I need to do is to push my work to this repo or the upstream i.e., actions/starter-workflows.

That would be amazing @tnir!

@stale
Copy link

stale bot commented Dec 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 13, 2022
@tdreyno tdreyno added notstale and removed stale labels Dec 13, 2022
@fcatuhe
Copy link

fcatuhe commented Aug 26, 2023

Hi, I created a PR for Middleman deploy starter workflow: actions/starter-workflows#2145.

Not sure if it will get merged, but in the meantime the workflow file can be used as a template:
https://github.com/actions/starter-workflows/blob/24174192b3b7074f5f178e47ebce10d0f1bd9ab3/pages/middleman.yml

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# Sample workflow for building and deploying a Middleman site to GitHub Pages

# To get started with Middleman see: https://middlemanapp.com/

name: Deploy Middleman site to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: [$default-branch]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@v3
      - name: Build with Middleman
        run: bundle exec middleman build
        env:
          BASE_URL: ${{ steps.pages.outputs.base_url }}
          NO_CONTRACTS: true
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v2
        with:
          path: ./build

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v2

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants