Github Action: [!] Error: Cannot find module 'rollup-plugin-commonjs' - github

In my package.json there are rollup and rollup-plugin-commonjs
but inside github actions it could not find those packages!
If I do not add rollup in global package installation step of github-action it shows that rollup is not found. But after adding both rollup and rollup-plugin-commonjs I get [!] Error: Cannot find module 'rollup-plugin-commonjs'
this is my workflow file:
name: Github Action
on:
push:
branches:
- fix/auto-test
jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout#v1
- name: Bootstrap app on Ubuntu
uses: actions/setup-node#v1
with:
node-version: '11.x.x'
- name: Install global packages
run: npm install -g prisma rollup rollup-plugin-commonjs
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Project dependencies test
uses: actions/cache#v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install project deps
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn
- name: Run docker
run: docker-compose -f docker-compose.test.prisma.yml up --build -d
- name: Sleep
uses: jakejarvis/wait-action#master
with:
time: '30s'
- name: Reset the database for safety
run: yarn reset:backend
- name: Deploy
run: yarn deploy:backend
- name: Build this great app
run: yarn build
- name: start app and worker concurrently and create some instances
run: |
yarn start &
yarn start:worker &
xvfb-run --auto-servernum yarn test:minimal:runner

Related

Github actions workflow error: You have an error in your yaml syntax

I am trying to deploy to google cloud engine using github actions and my yaml config is as follows,
name: "Deploy to GAE"
on:
push:
branches: [production]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Install Dependencies
run: composer install -n --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: GCP Authenticate
uses: GoogleCloudPlatform/github-actions/setup-gcloud#master
with:
version: "273.0.0"
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Set GCP_PROJECT
env:
GCP_PROJECT: ${{ secrets.GCP_PROJECT }}
run: gcloud --quiet config set project ${GCP_PROJECT}
- name: Deploy to GAE
run: gcloud app deploy app.yaml
and github actions is throwing me the below error
Invalid workflow file: .github/workflows/main.yml#L10
You have an error in your yaml syntax on line 10
fyi, line #10 is - uses: actions/checkout#v2
The steps indentation level is incorrect, it should be inside deploy
name: "Deploy to GAE"
on:
push:
branches: [production]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Install Dependencies
run: composer install -n --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: GCP Authenticate
uses: GoogleCloudPlatform/github-actions/setup-gcloud#master
with:
version: "273.0.0"
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Set GCP_PROJECT
env:
GCP_PROJECT: ${{ secrets.GCP_PROJECT }}
run: gcloud --quiet config set project ${GCP_PROJECT}
- name: Deploy to GAE
run: gcloud app deploy app.yaml

Github Actions restored cache is not being used

I'm having hard time figuring out how to make the pipeline use the restored cache of npm modules.
Here's the manifest file:
jobs:
setup-build-push-deploy:
name: Setup, Build, Push, and Deploy
runs-on: ubuntu-latest
steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout#v2
- name: Setup NodeJS
uses: actions/setup-node#v1
with:
node-version: '12.14'
# Cache the npm node modules
- name: Cache node modules
uses: actions/cache#v1
id: cache-node-modules
env:
CACHE_NAME: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ env.CACHE_NAME }}-${{ hashFiles('app/package-lock.json') }}
restore-keys: |
${{ env.CACHE_NAME }}-
# Install NPM dependencies
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
cd app/
npm install
# Compile Typescript to Javascript
- name: Compile Typescript
run: |
cd app/
npm run make
The "cache" step does make a successful cache hit, and therefore the "install dependencies" step is skipped. But then the "compile" step fails, because it cannot find any installed npm modules.
The docs here and here and the SO question, eg. here, do not specify any certain step or configuration that points towards where to pick up the cached modules from. Seems like they should be picked up automatically from ~/.npm, but that's not the case.
I was able to solve this by changing the path to node_modules:
Here's an example:
jobs:
prepare-npm-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 12.22.0
- name: Cache node modules
uses: actions/cache#v2
id: npm_cache_id
with:
path: node_modules
key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-cache-
${{ runner.os }}-
- name: Install Dependencies
if: steps.npm_cache_id.outputs.cache-hit != 'true'
run: npm ci
I found myself in the exact same situation.
The node_modules seems to be cached but then the next job immediately fails due to missing dependencies.
I ended up using this GitHub action by Gleb Bahmutov.
Specifically this part:
- uses: bahmutov/npm-install#v1.4.5
- run: npm install
- run: npm run ***
Detailed description can be found in this article:
https://glebbahmutov.com/blog/do-not-let-npm-cache-snowball/

Github action: UnhandledPromiseRejectionWarning: Error: Project not found: 'default#default' on while seeding database

on github action after deploying prisma I want to seed the database. but this gives me project not found error. why this error is showing even after prisma is deployed?
this is my yaml file
name: "Github Actions Test"
on:
push:
branches:
- wip/checkout2
jobs:
test:
runs-on: ubuntu-latest
env:
PRISMA_ENDPOINT: ${{secrets.PRISMA_ENDPOINT}}
PRISMA_SECRET: ${{secrets.PRISMA_SECRET}}
steps:
- uses: actions/checkout#v1
- name: "Install Node"
uses: actions/setup-node#v1
with:
node-version: "12.x"
- name: "Install global packages"
run: npm install -g yarn prisma-cli concurrently mocha wait-port
- name: "Run docker Container"
run: docker-compose -f docker-compose.yml up --build -d
- name: "Install deps"
run: yarn install
- name: "prisma deploy"
run: yarn deploy:backend
- name: "Seed Backend"
run: yarn seed:backend
- name: "Build app"
run: yarn build
- name: "Start backend and frontend concurrently on background and run tests"
run: |
yarn start &
yarn test

Github Actions deploy artifacts

Below workflow fails when deploying the artifacts to S3. In the last line, in the deployment job, it's complaining that ./build doesn't exist, probably because it can't find the artifacts.
The user-provided path ./build does not exist.
##[error]Process completed with exit code 255.
How do I make it recognise the artifacts created in the build job?
name: Build and deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-18.04
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: |
npm i -D
npm test --if-present
npm run build:prod
env:
CI: true
- name: Upload Artifact
uses: actions/upload-artifact#master
with:
name: build
path: build
deploy:
name: Deploy
needs: build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout#master
- name: Deploy to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 cp \
--recursive \
--acl public-read \
--region ap-southeast-2 \
./build s3://example
You need to download the artifact in the deploy job. See the actions/download-artifact action.
deploy:
name: Deploy
needs: build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout#master
- name: Download Artifact
uses: actions/download-artifact#master
with:
name: build
path: build
- name: Deploy to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 cp \
--recursive \
--acl public-read \
--region ap-southeast-2 \
./build s3://example

github action failing? tar empty archive, docker run failed with exit code 1

This is the project structure:
- parent/
|- .github/workflows/
|- frontend/
|- ...
This is the .yml file within workflows:
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- uses: actions/setup-node#v1
with:
node-version: "12.x"
- name: Install dependencies
working-directory: frontend
run: npm install
- name: Build
working-directory: frontend
run: npm run build
- name: Deploy Files
uses: appleboy/scp-action#master
env:
HOST: ${{ secrets.aws_pull_host }}
USERNAME: ${{ secrets.aws_pull_username }}
KEY: ${{ secrets.aws_pull_private_key }}
with:
working-directory: frontend
source: build/
target: "/home/build/site/testDir/"
strip_components: 1
Whenever the action gets to the step Deploy Files, i get the error:
tar: empty archive
tar all files into /tmp/891353322/bC24rHhFAi.tar
exit status 1
##[error]Docker run failed with exit code 1
First time working with github actions so I am pretty lost with this error. Appreciate any help.
Kept messing with it, finally figured it out:
- name: Deploy Files
uses: appleboy/scp-action#master
env:
HOST: ${{ secrets.aws_pull_host }}
USERNAME: ${{ secrets.aws_pull_username }}
KEY: ${{ secrets.aws_pull_private_key }}
with:
source: frontend/build/
target: "/home/build/site/testDir/"
strip_components: 1