withastro / action

A GitHub Action that deploys your Astro project to GitHub Pages
Other
143 stars 31 forks source link

Enable running action without a lock file #8

Closed torn4dom4n closed 1 year ago

torn4dom4n commented 1 year ago

Hi, I tried to use this action with my repo. And I see it doesn't run if my repo doesn't have a lock file. Please enable running this action without a lockfile.

mandar1jn commented 1 year ago

I believe that you can specify a package manager to use when no lock file is found using the package-manager input

torn4dom4n commented 1 year ago

I believe that you can specify a package manager to use when no lock file is found using the package-manager input

Sorry, I deleted my old repo. Now I use a new GitHub action with this code:

name: Deploy Astro site to Pages

on:
  push:
    branches: [main]

  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: true

defaults:
  run:
    shell: bash

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout your repository using git
        uses: actions/checkout@v3
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: "16"
      - name: Restore cache
        uses: actions/cache@v3
        with:
          path: |
            dist
          key: ${{ runner.os }}-astro-build-${{ hashFiles('dist') }}
          restore-keys: |
            ${{ runner.os }}-astro-build-
      - name: Install dependencies
        run: npm install
      - name: Build with Astro
        run: npm run build
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: ./dist

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

I'm not sure about I should keep this issue or close it because I still hope astro action can run without a lock file.

mandar1jn commented 1 year ago

As I said, I believe you can. After node-version, specify package-manager: PACKAGE-MANAGER. It’s mentioned in the readme of this repo too

torn4dom4n commented 1 year ago

As I said, I believe you can. After node-version, specify package-manager: PACKAGE-MANAGER. It’s mentioned in the readme of this repo too

You are right! I should close this.

natemoo-re commented 1 year ago

Thanks @mandar1jn and @torn4dom4n! For any future visitors, the following will work without a lockfile. You just need to specify with.package-manager: npm | yarn | pnpm.

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