Giter Club home page Giter Club logo

action's Introduction

Astro Deploy Action

This action for Astro builds your Astro project for GitHub Pages.

For more information, please see our complete deployment guide—Deploy your Astro Site to GitHub Pages.

Usage

Note: Want to get started even faster? Create a repository from our official GitHub Pages template!

Inputs

  • path - Optional: the root location of your Astro project inside the repository.
  • node-version - Optional: the specific version of Node that should be used to build your site. Defaults to 20.
  • package-manager - Optional: the Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. Accepted values: npm, yarn, pnpm, and bun. A version tag is also accepted, for example [email protected], pnpm@8, or bun@latest. If not provided, version will default to latest.

Example workflow:

Build and Deploy to GitHub Pages

Create a file at .github/workflows/deploy.yml with the following content.

name: Deploy to GitHub Pages

on:
  # Trigger the workflow every time you push to the `main` branch
  # Using a different branch name? Replace `main` with your branch’s name
  push:
    branches: [main]
  # Allows you to run this workflow manually from the Actions tab on GitHub.
  workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout your repository using git
        uses: actions/checkout@v4
      - name: Install, build, and upload your site output
        uses: withastro/action@v2
        # with:
            # path: . # The root location of your Astro project inside the repository. (optional)
            # node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
            # package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)

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

action's People

Contributors

adrianmg avatar colinhacks avatar leadingmoominexpert avatar mandar1jn avatar natemoo-re avatar nickmccurdy avatar princesseuh avatar samrith-s avatar swift502 avatar thatxliner avatar thinca avatar torn4dom4n 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

action's Issues

Allow Specifying Versions of setup-node and upload-pages-artifact

Hey folks, I just tried to use this action in a GHES environment and wasn't able to because the versions of setup-node and upload-pages-artifact aren't supported on my GHES version.

It would be great if I could specify which versions of these actions to allow compatibility with GHES.

Thanks!

Support `node-version-file` options of `actions/setup-node@v4`

Currently, available options of withastro/action@v2 is a subset of those of actions/setup-node@v4.
For example, node-version-file is not available.

In my usecase, I define Node.js as engines.node in package.json.
If I use actions/setup-node@v4 directly, I can specify node-version-file so that it reads the property.
Without this option, I have to manually sync Node.js versions in 2 files, workflow YAML file and package.json.

By the way, pnpm/action-setup@v3 automatically detects package manager and its version based on packageManager property in package.json, if package-manager of withastro/action@v2 is not specified, which enables me to manage package manager version in one place.

It may be fine to support other options of actions/setup-node@v4 too.

Actions fails with there are multiple locks files, even if path is set

I think, the Check lockfiles step should respect the path.

I've a repo that contains multiple package-lock.json files which causes this failure:

elif [ $(find "." -name "package-lock.json") ]; then 
/var/run/act/workflow/2-composite-0.sh: line 17: [: ./package-lock.json: binary operator expected

The $() variable contains multiple lines and this is something the [ doesn't like.

Using $(find ${{ inputs.path }} -name "package-lock.json") should do the trick.

Bun: Node Version Required

I have noticed that the package-manger bun@somthing still requires you to specify node_version.
I am willing to fix that issue.

Error: Some specified paths were not resolved, unable to cache dependencies.

Hi,

Thanks for this project. I am unable to deploy my documentation site using this action. I am getting the following error.

Error: Some specified paths were not resolved, unable to cache dependencies.

I think it is coming due to the fact that setup-node is trying to locate the cache inside apps/docs folder but since it is a monorepo, it is located two levels up.

From the job run, I noticed this:

cache-dependency-path: ./apps/docs/yarn.lock

There is no yarn.lock inside apps/docs since this is a monorepo.

Github job: https://github.com/codelitdev/courselit/actions/runs/4132972124/jobs/7142310620

Before today, it was working fine.

Setup Node step failing when in subfolder

Hi there I noticed that the Setup Node step is missing cache-dependency-path. Without this, if the user provides a path to a subfolder the build will fail as node won't be able to find the lockfiles since they are in the subfolder. Here's a picture of a build failing because of this issue:
Screenshot 2023-01-26 at 11 32 58 am

add input for custom `build` command

I have a repo where the docs are colocated with source, but crucially not as a monorepo, just sibling directories. My npm run build command builds source, not astro. Of course i can && npm run build:astro or something at the end, but that just complicates things. Nor do I want to make astro my main build script. Would be nice if it were configurable somehow, but default to build for backward compatibility.

Happy to make a PR if you think this is OK

Monorepo support

Maybe I am doing something wrong, but I cannot for the life of me deploy from a yarn workspaces monorepo.

I added the base:

// astro.config.msj
{
 base: '/docs',
}

Screenshot 2023-12-09 at 9 35 13 AM

It won't build properly because it won't build my other dependencies.

So if I remove the base, it fails because it can't find the docs/dist directory.

I need a way to build from the root and deploy from a path, but it doesn't seem as though one is exposed.

bug 🐛 v1.0.6 not compatible with action/deploy-pages v4 — isn't able to upgrade to node v20

I want to bump the action/deploy-pages version to v4 as it supports node 20 (actions/deploy-pages#256) but I am unable to do so because the current version of withastro/[email protected] is not compatible with it. I get this while running the workflow:

Fetching artifact metadata for "github-pages" in this workflow run
Found 0 artifact(s)
Error: Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages, or Actions? Please re-run the deployment at a later time.
Error: Error: No artifacts named "github-pages" were found for this workflow run. Ensure artifacts are uploaded with actions/artifact@v4 or later.
    at getArtifactMetadata (/home/runner/work/_actions/actions/deploy-pages/v4.0.3/src/internal/api-client.js:85:1)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Deployment.create (/home/runner/work/_actions/actions/deploy-pages/v4.0.3/src/internal/deployment.js:66:1)
    at main (/home/runner/work/_actions/actions/deploy-pages/v4.0.3/src/index.js:30:1)
Error: Error: No artifacts named "github-pages" were found for this workflow run. Ensure artifacts are uploaded with actions/artifact@v4 or later.

warning from github actions while using action/deploy-pages@v3:

[build](https://github.com/murtuzaalisurti/murtuzaalisurti.github.io/actions/runs/7684619378/job/20941330307)
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/upload-artifact@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Error with path: no such file or directory

I'm having this error on this repo

Running self-installer...
  [Error: ENOENT: no such file or directory, open '/home/runner/work/chinese-character-writing-practice/chinese-character-writing-practice/package.json'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/home/runner/work/chinese-character-writing-practice/chinese-character-writing-practice/package.json'
  }
  Error: Error: ENOENT: no such file or directory, open '/home/runner/work/chinese-character-writing-practice/chinese-character-writing-practice/package.json'

Path is assigned at workflow, but isn't working

How to provide `path` input?

My Astro site is located in the apps/docs directory of my project (a monorepo) and following is my deployment action file.

name: Deploy documentation

on:
  # Trigger the workflow every time you push to the `main` branch
  # Using a different branch name? Replace `main` with your branch’s name
  push:
    branches: [ main ]
  # Allows you to run this workflow manually from the Actions tab on GitHub.
  workflow_dispatch:
    inputs:
      path:
        description: 'Path to your Astro project'
        required: true
        default: './apps/docs'
        type: string
  
# Allow this job to clone the repo and create a page deployment
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout your repository using git
        uses: actions/checkout@v2          
      - name: Install, build, and upload your site
        uses: withastro/action@v0

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

The workflow is not running inside the specified folder i.e. apps/docs. What is the problem?

How to set environment variables before building?

I'm having a problem understanding how exactly it is I'm supposed to set the environment variables for my astro project that i'm deploying to github pages. I've set an environment variable inside my github repo but from what I understand it's not accessible through withastro/action@v1

Actions fail after update actions/deploy-pages action to v4

This is my GitHub Actions:

# To get started with Astro see: https://docs.astro.build/en/getting-started
name: Deploy Astro site to Pages

on:
  push:
    branches: ['main']

  # 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:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout your repository using git
        uses: actions/checkout@v4

      - name: Install, build, and upload your site
        uses: withastro/action@v1
        with:
          node-version: 20

  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@v4

And this is log with Deploy to GitHub Pages:

Fetching artifact metadata for github-pages in run 7264272115
Error: Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages or Actions? Please re-run the deployment at a later time.
Error: Error: No artifacts found for workflow run 7264272[11](https://github.com/MedPocket/18-months/actions/runs/7264272115/job/19791485992#step:2:12)5. Ensure artifacts are uploaded with actions/artifact@v4 or later.
    at getArtifactMetadata (/home/runner/work/_actions/actions/deploy-pages/v4/src/internal/api-client.js:24:1)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Deployment.create (/home/runner/work/_actions/actions/deploy-pages/v4/src/internal/deployment.js:66:1)
    at main (/home/runner/work/_actions/actions/deploy-pages/v4/src/index.js:30:1)
Error: Error: No artifacts found for workflow run 72642721[15](https://github.com/MedPocket/18-months/actions/runs/7264272115/job/19791485992#step:2:16). Ensure artifacts are uploaded with actions/artifact@v4 or later.

Cannot build Astro site with Node 20, "actions/checkout@v4" and "withastro/action@v2"

I bumped my Astro website Node version to 20 earlier today, but discovered I could no longer build and deploy via Github pages.

There's a related Node 20 bug, which is now closed.
And the related PR has been merged.

So... I have just modified my Github pages workflow YML with latest versions:
https://github.com/basher/basher-website/blob/master/.github/workflows/static.yml

But... I'm still getting build errors. The error doesn't provide me with any useful info:
https://github.com/basher/basher-website/actions/runs/7974519592/job/21770594265#step:3:41

Any ideas??? 🤔

need support for different pnpm versions

I'm using pnpm v8.6.1 locally and the CI uses the v7 version of pnpm. The mismatch of versions will cause errors in CI.

The discussion https://github.com/orgs/pnpm/discussions/6633 describes the same issue.

Logs

2023-06-30T15:41:58.5412888Z env:
2023-06-30T15:41:58.5413087Z   INPUT_PM: pnpm
2023-06-30T15:41:58.5413283Z ##[endgroup]
2023-06-30T15:41:58.5651094Z ##[group]Run pnpm/[email protected]
2023-06-30T15:41:58.5651344Z with:
2023-06-30T15:41:58.5651530Z   version: 7.x.x
2023-06-30T15:41:58.5651735Z   dest: ~/setup-pnpm
2023-06-30T15:41:58.5651942Z   run_install: null
2023-06-30T15:41:58.5652117Z env:
2023-06-30T15:41:58.5652311Z   PACKAGE_MANAGER: pnpm
2023-06-30T15:41:58.5652518Z ##[endgroup]
2023-06-30T15:41:58.6814194Z ##[warning]The `save-state` 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/
2023-06-30T15:41:58.6855768Z ##[group]Running self-installer...
2023-06-30T15:41:59.2019803Z Progress: resolved 1, reused 0, downloaded 0, added 0
2023-06-30T15:41:59.2122840Z Packages: +1
2023-06-30T15:41:59.2123272Z +
2023-06-30T15:41:59.9078948Z Packages are hard linked from the content-addressable store to the virtual store.
2023-06-30T15:41:59.9079890Z   Content-addressable store is at: /home/runner/.pnpm-store/v3
2023-06-30T15:41:59.9080964Z   Virtual store is at:             node_modules/.pnpm
2023-06-30T15:41:59.9338720Z 
2023-06-30T15:41:59.9339435Z dependencies:
2023-06-30T15:41:59.9340277Z + pnpm 7.33.2 (8.6.5 is available)
2023-06-30T15:41:59.9341316Z 
2023-06-30T15:42:00.2034805Z Progress: resolved 1, reused 0, downloaded 1, added 1, done
2023-06-30T15:42:00.2158390Z ##[endgroup]
2023-06-30T15:42:00.2162206Z Installation Completed!
2023-06-30T15:42:00.2166092Z 
2023-06-30T15:42:00.2170961Z ##[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/
2023-06-30T15:42:00.2173245Z 
2023-06-30T15:42:00.2174927Z ##[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/
2023-06-30T15:42:00.2300941Z ##[group]Run actions/setup-node@v3
2023-06-30T15:42:00.2301166Z with:
2023-06-30T15:42:00.2301356Z   node-version: 18
2023-06-30T15:42:00.2301542Z   cache: pnpm
2023-06-30T15:42:00.2301763Z   cache-dependency-path: ./
2023-06-30T15:42:00.2301995Z   always-auth: false
2023-06-30T15:42:00.2302195Z   check-latest: false
2023-06-30T15:42:00.2302502Z   token: ***
2023-06-30T15:42:00.2302700Z env:
2023-06-30T15:42:00.2302883Z   PACKAGE_MANAGER: pnpm
2023-06-30T15:42:00.2303151Z   PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
2023-06-30T15:42:00.2303396Z ##[endgroup]
2023-06-30T15:42:00.4370664Z Found in cache @ /opt/hostedtoolcache/node/18.16.1/x64
2023-06-30T15:42:00.4382087Z ##[group]Environment details
2023-06-30T15:42:01.0826454Z node: v18.16.1
2023-06-30T15:42:01.0826898Z npm: 9.5.1
2023-06-30T15:42:01.0827164Z yarn: 1.22.19
2023-06-30T15:42:01.0836030Z ##[endgroup]
2023-06-30T15:42:01.0840333Z [command]/home/runner/setup-pnpm/node_modules/.bin/pnpm store path --silent
2023-06-30T15:42:01.6174066Z /home/runner/setup-pnpm/node_modules/.bin/store/v3
2023-06-30T15:42:03.0397299Z pnpm cache is not found
2023-06-30T15:42:03.0488434Z ##[group]Run cd .
2023-06-30T15:42:03.0488642Z �[36;1mcd .�[0m
2023-06-30T15:42:03.0488853Z �[36;1m$PACKAGE_MANAGER install�[0m
2023-06-30T15:42:03.0542055Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2023-06-30T15:42:03.0542307Z env:
2023-06-30T15:42:03.0542673Z   PACKAGE_MANAGER: pnpm
2023-06-30T15:42:03.0542948Z   PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
2023-06-30T15:42:03.0543188Z ##[endgroup]
2023-06-30T15:42:03.6418968Z  ERR_PNPM_LOCKFILE_CONFIG_MISMATCH  Cannot proceed with the frozen installation. The current "settings.autoInstallPeers" configuration doesn't match the value found in the lockfile
2023-06-30T15:42:03.6419635Z 
2023-06-30T15:42:03.6421292Z Update your lockfile using "pnpm install --no-frozen-lockfile"
2023-06-30T15:42:03.6621404Z ##[error]Process completed with exit code 1.

Github Actions Config

name: Deploy to GitHub Pages

on:
  # Trigger the workflow every time you push to the `main` branch
  # Using a different branch name? Replace `main` with your branch’s name
  push:
    branches: [ main ]
  # Allows you to run this workflow manually from the Actions tab on GitHub.
  workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout your repository using git
        uses: actions/checkout@v3
      - name: Install, build, and upload your site
        uses: withastro/action@v0
        with:
            path: . # The root location of your Astro project inside the repository. (optional)
            node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 16. (optional)
            package-manager: pnpm # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)

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

timezone

i use datetime function.
but at the time of build using github action the results of the datetime are not as expected.
how to set timezone to Asia/Jakarta ?

Build Action fails to setup: Github doesn't recognize `working-directory`

Earlier builds passed with the log:

Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:f43a0e5ff2bd294095638e18286ca9a3d1956744)
Download action repository 'withastro/action@v1' (SHA:f122c0232093b3504e4c841a46c2eebd07c47392)
Getting action download info
Download action repository 'pnpm/action-setup@v2' (SHA:d882d12c64e032187b2edb46d3a0d003b7a43598)
Download action repository 'oven-sh/setup-bun@v1' (SHA:a1800f471a0bc25cddac36bb13e6f436ddf341d7)
Download action repository 'actions/setup-node@v3' (SHA:1a4442cacd436585916779262731d5b162bc6ec7)
Download action repository 'actions/upload-pages-artifact@v1' (SHA:84bb4cd4b733d5c320c9c9cfbc354937524f4d64)
Getting action download info
Download action repository 'actions/upload-artifact@v3' (SHA:a8a3f3ad30e3422c9c7b888a15615d19a852ae32)
Complete job name: build

However, a run triggered by the latest version resulted in:

Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:f43a0e5ff2bd294095638e18286ca9a3d1956744)
Download action repository 'withastro/action@v1' (SHA:64c331d10da115fbaab6c13ceb8d64f06199a703)
Error: withastro/action/v1/action.yml (Line: 96, Col: 7): Unexpected value 'working-directory'
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. withastro/action/v1/action.yml (Line: 96, Col: 7): Unexpected value 'working-directory'
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load withastro/action/v1/action.yml

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.