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.
Related
The following workflow.yml works as expected when comitting changes to my main branch for our Flutter web based application.
name: Build and deploy Node.js app to Azure Web App - myApp
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Node.js version
uses: actions/setup-node#v1
with:
node-version: '12.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy#v2
with:
app-name: 'myApp'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_MYAPP }}
package: .
But we are challenged to make the workflow to publish to an additional dev and beta branch, so that the website branches could be addressed like this:
main: myapp.azurewebsites.net
beta: beta.myapp.azurewebsites.net
dev: dev.myapp.azurewebsites.net
So how should the workflow.yml be to publish those two additional branches ?
Do I need to do some more in azure setting/enviroment or github to make it work ?
The branches in github are named 'main', 'beta' and 'dev'.
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
I have the following action set up in my private GitHub repo:
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.17.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: yarn install --frozen-lockfile
- run: yarn test
Previously, the node-version was set to [15.x] and everything worked wonderfully. Since updating the required Node version to 14.17.x I have a check in my PRs that never resolves. It says:
build (15.x) Expected — Waiting for status to be reported Required
What am I missing here? It’s almost as if something is cached.
The issue ended up being a required status check that was added in “Settings » Branches » Require status checks to pass before merging » Require branches to be up to date before merging”. I removed that status check and re-added the updated version, then the message disappeared from the Checks list in all open PRs.
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.
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.