A GitHub Action to enable Pages and extract various metadata about a site

Overview

configure-pages

A GitHub Action to enable Pages and extract various metadata about a site. It can also be used to configure various static site generators we support as starter workflows.

See set-pages-path.js for more details on how we configure static site generators to work "out of the box" with GitHub Pages.

Usage

See action.yml and the Pages starter workflows.

Release instructions

In order to release a new version of this Action:

  1. Locate the semantic version of the upcoming release (a draft is maintained by the draft-release workflow).

  2. Publish the draft release from the main branch with semantic version as the tag name, with the checkbox to publish to the GitHub Marketplace checked. ☑️

  3. After publishing the release, the release workflow will automatically run to create/update the corresponding the major version tag such as v0.

    ⚠️ Environment approval is required. Check the Release workflow run list.

License

The scripts and documentation in this project are released under the MIT License.

Comments
  • Add SvelteKit as an option for static_site_generator setting

    Add SvelteKit as an option for static_site_generator setting

    Add SvelteKit as an option for use as a static site generator.

    I had set up the config parsing changes earlier today, but I added the actual SvelteKit config code more recently based on @NatoBoram's snippet. In the snippet, he provided an example for setting a GITHUB_PAGES environment variable, which has been discussed in the same thread. I didn't include this just yet, as I might suggest moving it outside of the SvelteKit SSG option into a more global spot, since it may not be SvelteKit specific. This all depends on the outcome of the thread, though.

    opened by AndrewLester 6
  • Pages config is not injected when generators using with typescript

    Pages config is not injected when generators using with typescript

    Pages config is not injected when using gatsby-config.ts. Gatsby will ignore pathPrefix and build the site as if hosted from the root domain.

    To Reproduce

    1. Create Gatsby Project with TypeScript
    2. Add deploy action from template
    3. Run Workflow

    Run actions/configure-pages@v2

    Using default blank configuration
    Injecting property=pathPrefix and value=/temp-gatsby-starter-ts/ in:
    // Default Pages configuration for Gatsby
    module.exports = {}
    
    Found configuration object in direct module export
    Injection successful, new configuration:
    // Default Pages configuration for Gatsby
    module.exports = {pathPrefix: "/temp-gatsby-starter-ts/"}
    
    Injecting property=siteMetadata.siteUrl and value=https://bicstone.github.io/ in:
    // Default Pages configuration for Gatsby
    module.exports = {pathPrefix: "/temp-gatsby-starter-ts/"}
    
    Found configuration object in direct module export
    Injection successful, new configuration:
    // Default Pages configuration for Gatsby
    module.exports = {siteMetadata: {siteUrl: "https://bicstone.github.io/"},pathPrefix: "/temp-gatsby-starter-ts/"}
    
    Gatsby will ignore pathPrefix and build the site as if hosted from the root domain

    https://bicstone.github.io/temp-gatsby-starter-ts/

    opened by bicstone 3
  • Error when trying to build for NextJS 12.3

    Error when trying to build for NextJS 12.3

    The current injection for the default template causes a failure due to specifying the unoptimized value for images to be wrapped in an experimental block. const nextConfig = {experimental: {images: {unoptimized: true}},basePath: "/test"}

    However, as of 12.3 this is no longer necessary and will cause build failure of:

    Error: Image Optimization using Next.js' default loader is not compatible with next export.

    Workaround is to explicitly set the correct value in the next.config.js. Suggesting to either determine version or allow it to be specified in order to conditionally apply the experimental wrapper.

    Source: https://nextjs.org/blog/next-12-3#disable-image-optimization-stable

    opened by bobeagan 2
  • Use GitHub Pages site origin for setting up SSG configs

    Use GitHub Pages site origin for setting up SSG configs

    From what I could tell, two (SvelteKit and Gatsby) of the currently supported static site generators have a configuration option for the URL of the deployed site. This allows for code to access the site URL during prerendering, which is useful for social sharing, meta tags, JSON-LD, and more. Since configure-pages does have knowledge of this URL, I think it makes sense to pass it to the SSG configurations.

    Let me know if this was already discussed and decided against. Also, the other generators might support a similar config option, and I would be happy to add them to this PR.

    I got the name for Gatsby's config option from the docs. It's possible that users would want the pathPrefix also attached to the siteUrl, which is certainly possible. I didn't include it because it is accessible with library functions and in the previous tests with a siteURL (this was the capitalization before), it didn't include the pathPrefix.

    opened by AndrewLester 2
  • Add support for specifying the SSG configuration file path

    Add support for specifying the SSG configuration file path

    Fixes #5

    Example usage:

        steps:
          - name: Setup Pages
            id: pages
            uses: actions/configure-pages@ssg-config-file-input
            with:
              static_site_generator: next
              generator_config_file: some/relative/or/absolute/path/next.config.js
    

    I also added support for updating ESM syntax configuration files that do not have object literal expressions in the export default declaration.

    Known Issue: If the specified configuration file does not yet exist, we may end up writing the incorrect syntax (ESM vs. CommonJS, and vice versa) when creating the file.

    opened by JamesMGreene 2
  • Support for specifying folder

    Support for specifying folder

    My next project is in a monorepo, and therefore the next.config.js isn't on root.

    An input so I could specify the working directory would solve this for me.

    enhancement 
    opened by karl-run 2
  • Warn about unsupported file extensions

    Warn about unsupported file extensions

    Closes #28 Closes #29

    This check is somewhat inaccurate in that it is specifically checking against file extensions (which we don't care about) rather than the relevant language present within the configuration file, but it's a decent naive check to help clarify things for confused users when they try to configure unsupported languages like TypeScript. 🤷🏻‍♂️

    Thanks to @bicstone for mentioning it in #28 and laying the groundwork in #29. 💝

    opened by JamesMGreene 1
  • Add support for Astro configuration 🚀

    Add support for Astro configuration 🚀

    Following #38, we can add support for Astro's config files, which typically wrap their configurations with a defineConfig(...) call for better Intellisense support.

    P.S. Mentioned in #30.

    opened by JamesMGreene 1
  • Showing warning `'set-output' command is deprecated`

    Showing warning `'set-output' command is deprecated`

    While using this workflow, it is showing warning:

    The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
    

    Full log: https://github.com/arifszn/gitprofile/actions/runs/3306031156/jobs/5456613147#step:4:7

    opened by arifszn 1
  • PRUEBA

    PRUEBA

    Thank you 🙇‍♀ for wanting to create an issue in this repository. Before you do, please ensure you are filing the issue in the right place. Issues should only be opened on if the issue relates to code in this repository.

    If your issue is relevant to this repository, please delete this text and continue to create this issue. Thank you in advance.

    invalid 
    opened by ROXEIDI 1
  • Make Pages enablement (and write permissions) optional

    Make Pages enablement (and write permissions) optional

    Background

    Currently, if I try to run this Action without the pages: write permission on my workflow, it will fail even if the Pages site has already been enabled.

    I would love to only need to grant pages: read permission in workflows that I am confident should already have the Pages site enabled. 🤷🏻‍♂️

    Implementation Choices

    This PR implements 2 different enhancements in this area:

    1. It adds a new optional Action input called enablement that defaults to "true" but can be set to "false" to explicitly disallow the Action from attempting to create/enable the Pages site if it does not already exist

    2. It alters the Action's internal flow in such a way that the 1-3 API calls are all consolidated into a single entrypoint so we can:

      • utilize them more efficiently, i.e. potentially avoid the need for the pages: write permission
      • extract the API calls out of the other local modules so that they only deal with model/domain objects, thus making their unit tests much simpler without the need to mock HTTP responses
    opened by JamesMGreene 1
  • Configuration seems to struggle with Next.js PWA configurations

    Configuration seems to struggle with Next.js PWA configurations

    I am working on migrating a web application to Next.js in this repo. However, I am running into an issue where the basePath is seemingly not injected.

    My configuration looks like the following:

    const withPWA = require("next-pwa")({
    	dest: "public",
    });
    
    module.exports = withPWA({
    	compiler: {
    		styledComponents: true,
    	},
    	reactStrictMode: true,
    });
    

    However, the step using the actions/configure-pages action outputs this warning from #43:

    Warning: Unsupported configuration file extension. Currently supported extensions: ".js", ".cjs", ".mjs"

    Other than the fact that the next.config.js configuration uses the .js extension, it seems that the action fails to inject properties into a configuration wrapped by a higher-order withPWA function. A more useful error is not logged, so this issue is hard to diagnose.

    opened by haykam821 0
  • Create Pages site failed: Resource not accessible by integration

    Create Pages site failed: Resource not accessible by integration

    Related: https://github.com/actions/starter-workflows/issues/332

    The repo's actions permissions are already set to read and write by default. Also tried setting permissions: write-all on the job. Also tried triggering on push, which I could've sworn was working yesterday. Nothing is working today.

    name: Perform first-time setup of repo
    
    on: create
    
    jobs:
      setup:
        runs-on: ubuntu-latest
        steps:
          - name: Enable GitHub Pages
            uses: actions/configure-pages@v2
    
    Run actions/configure-pages@v2
      with:
        token: ***
        enablement: true
      
    Warning: Get Pages site failed
    Error: Create Pages site failed
    Error: AxiosError: Request failed with status code 40[3]
    

    I also tried enabling Pages more directly with the GitHub API, and still got an error:

    name: Perform first-time setup of repo
    
    on: create
    
    jobs:
      setup:
        runs-on: ubuntu-latest
        steps:
          - name: Enable GitHub Pages
            id: url
            uses: actions/github-script@v6
            with:
              script: |
                return (await github.rest.repos.createPagesSite({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                })).html_url;
    
    with:
        script: return (await github.rest.repos.createPagesSite({
        owner: context.repo.owner,
        repo: context.repo.repo,
        build_type: "legacy",
      })).html_url;
      
        github-token: ***
        debug: false
        user-agent: actions/github-script
        result-encoding: json
        retries: 0
        retry-exempt-status-codes: 400,401,40[3](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:3),[4](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:4)04,422
    RequestError [HttpError]: Resource not accessible by integration
        at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:6172:21
    Error: Unhandled error: HttpError: Resource not accessible by integration
        at processTicksAndRejections (node:internal/process/task_queues:96:[5](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:5))
        at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v[6](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:6)/dist/index.js:13356:16), <anonymous>:3:9)
        at async main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:13452:20) {
      status: 403,
      response: {
        url: 'https://api.github.com/repos/vincerubinetti/lab-website-template/pages',
        status: 403,
        headers: {
          'access-control-allow-origin': '*',
          'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
          connection: 'close',
          'content-encoding': 'gzip',
          'content-security-policy': "default-src 'none'",
          'content-type': 'application/json; charset=utf-8',
          date: 'Wed, 23 Nov 2022 02:55:23 GMT',
          'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
          server: 'GitHub.com',
          'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
          'transfer-encoding': 'chunked',
          vary: 'Accept-Encoding, Accept, X-Requested-With',
          'x-content-type-options': 'nosniff',
          'x-frame-options': 'deny',
          'x-github-media-type': 'github.v3',
          'x-github-request-id': '0402:0C51:2[7](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:7)629CE:507BEC5:637D[8](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:8)B[9](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:9)B',
          'x-ratelimit-limit': '[10](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:10)00',
          'x-ratelimit-remaining': '999',
          'x-ratelimit-reset': '1669175723',
          'x-ratelimit-resource': 'core',
          'x-ratelimit-used': '1',
          'x-xss-protection': '0'
        },
        data: {
          message: 'Resource not accessible by integration',
          documentation_url: 'https://docs.github.com/rest/pages#create-a-github-pages-site'
        }
      },
      request: {
        method: 'POST',
        url: 'https://api.github.com/repos/vincerubinetti/lab-website-template/pages',
        headers: {
          accept: 'application/vnd.github.-preview+json',
          'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/16.[13](https://github.com/vincerubinetti/lab-website-template/actions/runs/3528824640/jobs/5919310323#step:2:13).0 (linux; x64)',
          authorization: 'token [REDACTED]',
          'content-type': 'application/json; charset=utf-8'
        },
        body: '{"build_type":"legacy"}',
        request: { agent: [Agent], hook: [Function: bound bound register] }
      }
    }
    
    opened by vincerubinetti 7
  • Add note to include `deployment` as typical trigger when using this action?

    Add note to include `deployment` as typical trigger when using this action?

    I know technically this would be a change to the starter workflows repository, but since I think it only applies when you're using this action, I've created the issue here.

    One thing I was wondering about is how to make this action run whenever the baseurl of the GitHub Pages site changed. As far as I can tell, that would happen when 1) GitHub Pages is first enabled, 2) when the repo name changes, or 3) the custom domain field changes. It doesn't seem like there are any workflow triggers that hook into a repo's settings, but there is the deployment trigger, which (as I interpret it, and in my testing) runs after each time the repo's GitHub Pages is deployed (is there any other kind of "deployment"?).

    As such, if you're using this action to get the most up to date baseurl, I think you need to run it on the deployment trigger. Unfortunately this means that if you're making a commit based off of the change -- e.g. updating baseurl in _config.yaml -- then pages will build once, then run this action, then make the commit which will make pages build again. So you get duplicate builds, but I don't see a way around it unless GitHub adds more triggers.

    Anyway, maybe you could add a note about using this trigger to the readme here?

    Or maybe there's a better way that I don't know of?

    opened by vincerubinetti 2
Releases(v2.1.3)
  • v2.1.3(Nov 23, 2022)

    Changelog

    • Warn about unsupported file extensions @JamesMGreene (#43)
    • Update to the latest actions/publish-action @JamesMGreene (#42)
    • Test: Better support alternative file extensions for blank config files @JamesMGreene (#41)
    • Support wrapped exports @JamesMGreene (#38)
    • Merge PR #33 @JamesMGreene (#37)
    • Bump actions @yoannchaudet (#35)

    See details of all code changes since previous release.

    Source code(tar.gz)
    Source code(zip)
  • v2.1.2(Oct 24, 2022)

  • v2.1.1(Sep 26, 2022)

    Changelog

    • Fix non-Code links in README @JamesMGreene (#27)
    • Clean up some unused dependencies @JamesMGreene (#26)
    • Add ESLint @JamesMGreene (#25)
    • Expand Prettier usage @JamesMGreene (#24)

    See details of all code changes since previous release.

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Sep 11, 2022)

    Changelog

    • Apply consistent spacing and use of single quotes @JamesMGreene (https://github.com/actions/configure-pages/commit/45efe609374726fd94570f0e5a4c32f41675e823)
    • Use GitHub Pages site origin for setting up SSG configs @AndrewLester (#21)
    • Update major version only on full releases @JamesMGreene (#20)

    See details of all code changes since previous release.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Aug 19, 2022)

  • v1.2.1(Aug 18, 2022)

  • v1.2.0(Aug 17, 2022)

    Changelog

    • Add SvelteKit as an option for static_site_generator setting @AndrewLester (#16)
    • Improve a few contribution notes in the README @JamesMGreene (#12)
    • Rename to include "GitHub" in "GitHub Pages" for Marketplace @JamesMGreene (#17)
    • Add support for specifying the SSG configuration file path @JamesMGreene (#15)
    • Prettier formatting @JamesMGreene (#13)
    • Workflow audit @JamesMGreene (#14)

    See details of all code changes since previous release.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Aug 5, 2022)

    Changelog

    • Improve Actions manifest @JamesMGreene (#11)
    • Add workflow to verify distributables are built @JamesMGreene (#9)
    • Cleanup formatting of test workflow @JamesMGreene (#8)
    • Correct a few metadata field values in the package.json @JamesMGreene (#7)
    • Make Pages enablement (and write permissions) optional @JamesMGreene (#6)
    • Fix hardcoded api endpoint @YiMysty (#10)

    See details of all code changes since previous release.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Jul 26, 2022)

  • v0.1.0(Jul 13, 2022)

Owner
GitHub Actions
Automate your GitHub workflows
GitHub Actions
This project is used to extract media from various posting platfroms like Twitter, Reddit, Pixiv, Youtube and many other

Social-Picker-API This project is used to extract media from various posting platfroms like Twitter, Reddit, Pixiv, Youtube and many others. It's writ

Serge 11 Nov 29, 2022
A util for getting data and metadata for all markdown files in a given dir. Useful for building static site generators

extract-md-data A util for getting data and metadata for all markdown files in a given dir. Useful for building static site generators. Usage Given th

Claire Froelich 2 Jan 6, 2022
This project will be using various AI and Rule Engine algorithm to detect various attack against a company!

?? Introduction This project will be using various AI and Rule Engine algorithm to detect various attack against a website! ?? Mission After starting

Harish S.G 4 Apr 29, 2022
A Docusaurus website deployed to GitHub Pages using GitHub Actions.

Deploy Docusaurus website to GitHub Pages using GitHub Actions This repository is an example of deploying a Docusaurus website to GitHub Pages using G

Lars Gyrup Brink Nielsen 18 Dec 26, 2022
GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (istanbul)

GitHub Action: Report NYC coverage GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (ista

Sid 16 Nov 23, 2022
A GitHub action to submit your dependency graph from your Mill build to GitHub.

Mill Dependency Submission A GitHub action to submit your dependency graph from your Mill build to GitHub via their Dependency Submission API. The mai

Chris Kipp 6 Dec 15, 2022
A GitHub Action that allows to debug GitHub workflows using VS Code.

VS Code Server Action A GitHub Action that allows to debug GitHub workflows using VS Code. Failing CI builds can be annoying especially since we don't

stateful 18 Dec 23, 2022
A set of scripts to test markdown processing speeds in various site generators/frameworks

bench-framework-markdown A set of scripts to test markdown processing speeds in various site generators/frameworks. Read the blog post: Which Generato

Zach Leatherman 24 Nov 3, 2022
This site compares your GitHub Profile to your friends, and analyses and tells your GitHub profile score too.

GitHub ⚔️ Duel Deployed at ?? : https://githubduel.vercel.app/ Compare your GitHub profiles with your friends It gives score to GitHub profile based o

Anshuman swain 17 Nov 21, 2022
Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collections

eznft Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collec

null 3 Sep 21, 2022
A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview ?? It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Yazan Zoghbi 2 Apr 22, 2022
A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview ?? It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Yazan Zoghbi 2 Apr 22, 2022
A plugin for Obsidian that can create input fields inside your notes and bind them to metadata fields.

Obsidian Meta Bind Plugin This plugin can create input fields inside your notes and bind them to metadata fields. New docs I am currently working on n

Moritz Jung 57 Jan 4, 2023
For data quality enthousiasts (and dataview lovers): manage the metadata of your notes.

Metadata Menu This plugin is made for data quality enthousiasts: access and manage the metadata of your notes in Obsidian. Metadata Menu adds context

mathieu 139 Dec 23, 2022
🎨 Dynamic Token Images and Metadata

ERC721K - Dynamic Token Images and Metadata Overview ERC721K is an ERC721 implementation with zero dependencies for off-chain data. Both the token ima

ERC721K 142 Dec 29, 2022
🎨 Dynamic Token Images and Metadata

ERC721K - Dynamic Token Images and Metadata Overview ERC721K is an ERC721 implementation with zero dependencies for off-chain data. Both the token ima

ERC721K 131 Sep 30, 2022
Dual ownership for NFTs, preventing rugs when collection metadata/royalties are changed

Multisig Ownable Opensea only allows EOAs to make changes to collections, which makes it impossible to use multisigs to secure NFT contracts since whe

Tubby Cats 28 Nov 24, 2022
A collection of crypto tokens (metadata, logos, links)

@deliquid/token-list (beta) A multi-chain collection of crypto tokens, including metadata, logos, and more. Installation npm i @deliquid/token-list Ba

DeLiquid 4 Jun 3, 2022
Fetch publication metadata from the INSPIRE-HEP database

Zotero INSPIRE Metadata Updater This is an add-on for the excellent open-source reference manager Zotero. It is useful as most papers from arXiv will

null 20 Nov 27, 2022