GitHub Actions Disable Auto Cancel When Job Fails - github

I have the following GitHub Actions config file (parts removed for simplicity).
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 13.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
The major problem I'm running into is that lets say the test for Node.js version 8 fails. But the rest succeed. In that event GitHub Actions tends to cancel all the jobs if one job fails.
Is there a way to change this behavior so all jobs will continue to run even if one has a failure? This can be helpful in pinpointing an issue with a specific version.

Adding fail-fast: false under strategy works fines for me! :)
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 13.x]
fail-fast: false
steps:
- uses: actions/checkout#v2
- name: Use Node.js
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test

Related

Versions and Tags Not Being Created Properly on Github

I have modified the Github workflow on a practice app to make it change version and patch with every push to the master branch.
In Github workflows - it says this process has been successful:
However when I check under releases and tags - no releases or tags are listed.
Is there something I'm missing, here is my pipeline.yml
name: Deployment pipeline
on:
push:
branches:
- master
pull_request:
branches: [master]
types: [opened, synchronize]
jobs:
simple_deployment_pipeline:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: '16'
- name: npm install
run: npm install
- name: lint
run: npm run eslint
- name: build
run: npm run build
- name: test
run: npm run test
- name: e2e tests
uses: cypress-io/github-action#v4
with:
build: npm run
start: npm run start-prod
wait-on: http://localhost:5000
tag_release:
needs: [simple_deployment_pipeline]
runs-on: ubuntu-20.04
steps:
- name: Bump version and push tag
uses: anothrNick/github-tag-action#1.36.0
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: patch
RELEASE_BRANCHES: master
The log under tag_release looks like this:
Your problem, which can be inferred by the error message, is that you haven't checked out the code inside the job. This is noted in the readme of the dependent action.
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout#v3
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action#v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This is a common mistake, many assume that the code should exist in the job by default, but once you get varying type of workflows you will understand some use cases where you don't actually need to checkout the local git repo.
Take a look at the action you are using and consider sticking to the #v1 tag or at the very least pick a more recent version (1.36 is over a year old).

how to run GitHub Action after outage?

As you may (or may not) know yesterday was a major incident of GitHub's services: https://www.githubstatus.com/incidents/tyc8wpsgr2r8.
Unfortunately I published a release during that time and the action responsible for building and publishing the code didn't trigger.
For actions which were executed at least once I have an option to "Re-run workflow" - but how can I proceed with an action which didn't even trigger - I can not see it anywhere whatsoever?
I think the last resort would be to just make another release, remove the problematic one etc. but I'd like to avoid that.
The workflow file:
name: Node.js CI
on:
push:
branches: [master]
release:
types: [published]
pull_request:
branches: [master]
jobs:
test:
name: Test Node.js v${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 16
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install --production=false --no-package-lock
- name: Lint 💅🏻
run: npm run lint
- run: npm test
release:
name: Publish NPM Package
if: startsWith(github.ref, 'refs/tags/')
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm install --production=false --no-package-lock
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
gh-pages:
name: Publish GitHub Pages
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
needs:
- test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Install ✔️
run: npm install --production=false --no-package-lock
- name: Build storybook 🏗️
run: npm run build-storybook
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action#4.1.3
with:
branch: gh-pages
folder: storybook-static
As you said in the comment, the easiest solution would be to remove the release and create it all over again.
Another option could be to add a workflow_dispatch event trigger to the workflow with a tag input, updating the jobs condition to use this input.tag variable if informed.
That way, if an automatic trigger failed (through push, release or pull_request), you could trigger it manually through the Github UI or the GH CLI as an alternative.

github action runner showing "idle" and not updating the main website

I have been using DigitalOcean: if I change or commit repository the website not being updated.
I am using just one master branch, I had 23 file changes but on the site no effects.
here is my action code:
name: Node.js CI
on:
push:
branches: [ master ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i
- run: npm run build --if-present
- run: npm test
if I change or commit repository the website not being updated.
I am using just one master branch,
First, a change or commits are local actions: you need to push (git push) to GitHub in order for any action to have a chance to run.
Second, assuming that you have pushed, but your workflow was not triggered, add a on: directive (that you have) and double-check your default branch: recent repositories are using main, not master.
You can see an example in the official GitHub documentation "Building and testing Node.js / Starting with the Node.js workflow template":
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
Third, if you need to see some effect on a DigitalOcean Droplet, you might need to use digitalocean/action-doctl, in order to deploy (to DigitalOcean) what your GitHub action has build on GitHub side.

Github actions how to do npm install only 1 time

I'm using GitHub actions for deploy. And i need to build vuejs app, every time when pushing. Now all working coorectly, but every time i spend action minutes for npm install.
Can i install modules 1 time, and not reinstall it after every deploy?
on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
steps:
- name: 🚚 Get latest code
uses: actions/checkout#v2.3.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install --legacy-peer-deps
- run: npm run build
- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action#4.0.0
with:
server: ${{ secrets.host}}
username: ${{ secrets.user}}
password: ${{ secrets.pass }}
local-dir: dist/
dangerous-clean-slate: true

New GitHub actions run in empty folders

I am working with new GitHub actions, idea of a workflow below is to run when pr is opened or synchronised, it should first check out and install dependencies and afterwards run few yarn scripts
name: PR to Master
on:
pull_request:
branches:
- master
jobs:
# Synchronize or Opened
synchronized_or_opened:
name: Synchronize or Opened
runs-on: ubuntu-latest
steps:
- uses: actions/bin/filter#master
with:
args: action 'opened|synchronize'
# Add Labels
add_labels:
name: Add Labels
runs-on: ubuntu-latest
steps:
- uses: actions/labeler#v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
needs: synchronized_or_opened
# Checkout
checkout:
name: Checkout
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
needs: synchronized_or_opened
# Install Dependencies
install_dependencies:
name: Install Dependencies
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- run: yarn dep:install-npm
needs: checkout
# Typecheck
typecheck:
name: Typecheck
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- run: yarn typecheck
needs: install_dependencies
# Prettier
prettier:
name: Prettier
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- run: yarn prettier
needs: install_dependencies
# ESLint
eslint:
name: ESlint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- run: yarn eslint
needs: install_dependencies
# Danger
danger:
name: Danger
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- run: yarn danger
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs: install_dependencies
At the moment it successfully gets to a checkout stage, but once Install job is ran I get following error
error Couldn't find a package.json file in
"/home/runner/work/myRepo/myRepo"
Judging by this checkout either failed or I am in a wrong folder?
As mentioned in the Workflow syntax docs:
Each job runs in a fresh instance of the virtual environment specified by runs-on.
From what I can see here, you're doing the checkout step in a completely separate job from others. Doing it that way it does not affect other jobs in any way. It should actually be defined inside those jobs where your npm CLI commands are executed.
Here's an example of how it would look like in one of your jobs:
jobs:
# (...) Other jobs
# Install Dependencies
install_dependencies:
name: Install Dependencies
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout#master
- run: yarn dep:install-npm
needs: checkout
# (...) Other jobs
There are some general examples in GitHub starter workflow templates.