Github action for pull request not running - github

Github actions on pull request were working yesterday. Today they are not running.
.github/workflows/pull_request.yml looks like
name: Pull Request
on:
pull_request:
paths-ignore:
- '.github/**'
jobs:
black_and_flake8:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout#v3
- name: "Lint project"
uses: ./.github/actions/lint_project
test_common:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout#v3
- name: "Test common"
uses: ./.github/actions/test_common
test_dags:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout#v3
- name: "Test dags"
uses: ./.github/actions/test_dags
[etc there are a lot of jobs for different parts of this repo]
For example, ./github/actions/test_dags has a single action.yml file inside that looks like this
name: "test_dags"
description: "Tests for code that lives in /dags"
runs:
using: "composite"
steps:
- name: Run pytest
working-directory: dags
run: |
docker build -t dagtest -f Dockerfile.airflow_dags_test .
docker run --name=dagtestimage dagtest
docker cp dagtestimage:/tmp/htmlcov .
shell: bash
- uses: actions/upload-artifact#v3
with:
name: dags_htmlcov
path: /home/runner/work/processing/processing/dags/htmlcov/
Putting aside that there may be a smarter way to run these tests, why are no actions being fired at all when I make a pull request now? It happily ran all my checks yesterday. Nothing has merged into main related to github actions- just some pytest stuff for one of the modules, and that ran the checks.
My PR is changing the dockerfile referenced in the action above, updating requirements.txt, and to debug I changed a python file (in case those file types were magically excluded).
The GUI for the PR doesn't show any checks. Nothing new shows up in the Actions tab.
How do I figure out why this isn't working?

Turns out github is having an issue - https://www.githubstatus.com/ said everything was green when I posted this, but it has since updated to
Incident with GitHub Actions, API Requests, Codespaces, Git Operations, GitHub Packages, and GitHub Pages

Related

How to create a custom badge in Github actions

I have a simple Resume generator repo. It has a pipeline that runs the script where a markdown resume will be converted to a pdf file.
It creates downloadable content as shown below
This workflow looks nice but every time I want to download the artifact I have to navigate to the actions tab check the latest job and then download the file.
I was wondering if there is an option to create a special badge for it, which can be referenced in the readme, and when I click it would trigger the latest artifact download.
Artifact download link looks like this
https://github.com/n1md7/resume/suites/5221025505/artifacts/160003915
I looked a bit and it turned out there is one option in the marketplace. Bring your own badge
I tried to use it and it works as it generates a custom badge. However, in my use case, I need to inject a download link which is dynamic.
Any ideas on how can I achieve that?
This is my current workflow
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
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'
- name: Install Dependencies
run: npm ci
- name: Generate PDF from MarkDown
run: npm run generate
- name: Archive generated file
uses: actions/upload-artifact#v2
with:
name: RESUME-latest.pdf
path: RESUME.pdf
badge_job:
runs-on: ubuntu-latest
steps:
- id: download
# Change me
run: echo "##[set-output name=data;]$(date)"
- name: Download badge
uses: RubbaBoy/BYOB#v1.2.1
with:
NAME: Download
LABEL: 'Download resume'
STATUS: ${{ steps.download.outputs.data }}
COLOR: 00EEFF
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
REPOSITORY: n1md7/resume
ACTOR: n1md7
When the file is generated I'd like to pass that file path to badge_job (or combined) to be included somehow.

error "gatsby-source-github-api" threw an error while running the sourceNodes lifecycle: token is undefined

I am new to Gatsby and just tried a GH Actions workflow for my site today. I see this error at the build stage:
error "gatsby-source-github-api" threw an error while running the
sourceNodes lifecycle: token is undefined
I am using this to pull all repos on my Github into the site.
What I have tried so far:
Checked the Github personal access token
the build is working locally
Versions:
"gatsby-source-github-api": "^0.2.1" "gatsby": "^2.26.1"
This is my node.js.yml GH Actions workflow file:
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [13.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#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
PS: I have used a .env file to hold the value of the token that the plugin 'gatsby-source-github-api' requires. And it is in my .gitignore file. So which means it is not sent to GH and hence can't find it?
So that was it -- the .env file which wasn't being pushed to Github.
So I needed to make the token available to the GH Action build somehow.
I tried the action SpicyPizza/create-envfile#v1. It isn't supported by Github but seemed to do the job. It creates a .env file at build with the keys you provide it.
You could also create a .env file manually. See thread.

Github actions: Can the effects of one job trigger another?

I want to define a workflow as follows, for a node.js repo:
When new code is merged into master AND version in package.json is changed, create a new Github release for that version
When a new Github release is created, publish package to NPM
What I hope to achieve is that in our most typical workflow (PR merged to master) a release s created and package is automatically uploaded to NPM but to also be able to trigger an upload to NPM directly from a feature branch (usually a pre-release version, 1.0.3-rc1) by manually creating a release from such branch.
I've set up two Github workflows, each with a single job.
The first:
name: Create release on new version merge
on:
push:
branches:
- master
jobs:
release-on-new-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Check for version change
id: check
uses: EndBug/version-check#v1
with:
file-url: ::before
static-checking: localIsNew
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log when changed
if: steps.check.outputs.changed == 'true'
run: 'echo "Version change found: ${{ steps.check.outputs.version }}"'
- name: Create Release
if: steps.check.outputs.changed == 'true'
id: create_release
uses: actions/create-release#v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.check.outputs.version }}
release_name: v${{ steps.check.outputs.version }}...
The second:
name: Publish on new release
on:
release:
types: created
jobs:
publish-on-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Individually these workflows work as expected: When I merge some work onto master that changes the version number a release is created, and when I manually create a release it gets published to NPM. However I would also expect the release created as the effect of the first workflow to trigger the second flow and therefore when I merge a version change into master eventually automatically see it published to NPM. But to my amazement that does not happen. Is there some sort of mechanism that prevents the effects of one job to (indirectly) trigger another? Or am I missing something?
You might consider to explicitly mention the dependency of one job needed another job, using needs.
You can see that approach illustrated with:
"GitHub Actions: Dependent Jobs" from Edward Thomson (who is also on Stack Overflow)
That would allow to define a third action which would need the first two, forcing them to be chained in their execution.

Is it possible to not run github action for readme updates?

I have the following action on Github actions that automatically packs and deploy a package to nuget.org every time a PR gets merged into master.
name: Nuget Deploy
on:
push:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Generate Nuget package
run: dotnet pack
working-directory: DateOverride
- name: Deploy to nuget.org
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_DEPLOY_KEY }} -s https://api.nuget.org/v3/index.json
working-directory: DateOverride/DateOverride/bin/Debug
But I would like that it was not run if my update is only a README.md update, is it possible to do so?
I'd think the paths-ignore setting should help:
on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
You might want to combine your current GitHiub Action with another like MarceloPrado/has-changed-path
This action outputs whether a path or combination of paths has changed in the previous commit.
[This] action is meant to be used inside your job steps, not at the root of your workflow file
Or (opposite filter): dorny/paths-filter
With this Github Action you can execute your workflow steps only if relevant files are modified.

github action: run a test file on pull request

I want to run a test file when someone sends a pull request.
This is my action.yml file.
name: "GitHub Actions Test"
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
# - uses: actions/checkout#v1
- name: 'Install Node'
uses: actions/setup-node#v1
- name: Install mocha
run: npm install -g mocha
- name: Install dependencies
run: npm install
- name: "Run Test"
run: mocha test-mocha.test.js
but when running the test from github, I got the following error:
Error: No test files found: "test-mocha.test.js"
I wonder something is wrong on the last line of my yml file.
how to fix this?
This is because you've commented out the line that checks out your code:
# - uses: actions/checkout#v1 # Remove the comment from this line
By default, your code is not checked out in the workflow's directory. As such, you have to use the Checkout GitHub Action to check out your code.
From the README:
This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.