Exclude Directories from a Scheduled Github Action - github-actions

I am creating a github action to run on a schedule. The purpose of the action is to pull my pypi package pip install alphavantage_api_client then run python app.py to verify my published package is working correctly. To make this work, I need to exclude the internal client source code with something like paths-ignore but it's not working. How do I exclude a directory within a github action? Here is my github action config:
name: Daily End to End Tests with Alphavantage API PyPi
on:
schedule:
- cron: "0 */12 * * *"
paths-ignore:
- alphvantage_api_client
permissions:
contents: read
env:
ALPHAVANTAGE_API_KEY: "${{ secrets.ALPHAVANTAGE_API_KEY }}"
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: "Daily End to End Tests"
steps:
- uses: actions/checkout#v3
- name: Set up Python 3.10
uses: actions/setup-python#v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install alphavantage_api_client
python app.py
The error i get from the above is a syntax error with the paths-ignore, so i can see there is a problem.
I've referenced the documentation here
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-excluding-paths=
but i don't see a way to exclude paths for a scheduled action. Can someone point me in the right direction?

Related

Backstage Unable to use mkdocs to create Tech Docs for an existing component

I have enabled Github actions to create Tech docs after a commit. Below is the workflow file written to create Md files. But "techdocs-cli generate --no-docker --verbose" command fails with the below error. Can someone please help with the issue?
Failed to generate docs from /home/runner/work/myapp3/myapp3 into /home/runner/work/myapp3/myapp3/site; caused by unknown error 'Command mkdocs failed, exit code: 1'
workflow file:
name: Publish TechDocs Site
on:
push:
branches: master
jobs:
publish-techdocs-site:
runs-on: ubuntu-latest
env:
TECHDOCS_S3_BUCKET_NAME: XXX
AWS_ACCESS_KEY_ID: XXX
AWS_SECRET_ACCESS_KEY: XXX
AWS_REGION: XXX
ENTITY_NAMESPACE: 'default'
ENTITY_KIND: 'Component'
ENTITY_NAME: ‘XXX’
steps:
- name: Checkout code
uses: actions/checkout#v2
- uses: actions/setup-node#v2
- uses: actions/setup-python#v2
- name: Install techdocs-cli
run: sudo npm install -g #techdocs/cli
- name: Install mkdocs and mkdocs plugins
run: python -m pip install mkdocs-techdocs-core==1.*
- name: Generate docs site
run: techdocs-cli generate --no-docker --verbose
- name: Publish docs site
run: techdocs-cli publish --publisher-type awsS3 --storage-name $TECHDOCS_S3_BUCKET_NAME --entity $ENTITY_NAMESPACE/$ENTITY_KIND/$ENTITY_NAME
I had the same issue and it was resolved once you had the right folder structure where you have the mkdocs.yml file.
As long as you have a docs folder in the same root structure with the .md file that needs to be published.
The same .md file needs to be configured in the navigation section of the mkdocs.yml file as well

facing a permission issue when build react app in GitHub actions

This is my GitHub Actions script to build a react project:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 14
- name: Install yarn
uses: borales/actions-yarn#v2.1.0
- name: Build React App
run: |
sudo rm -rf node_modules
yarn
umi build
when I run this project in GitHub actions, shows error:
warning "umi-serve > #babel/preset-typescript#7.3.3" has unmet peer dependency "#babel/core#^7.0.0-0".
warning "umi-serve > #babel/register#7.4.4" has unmet peer dependency "#babel/core#^7.0.0-0".
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
[5/5] Building fresh packages...
error An unexpected error occurred: "EACCES: permission denied, open '/home/runner/work/admin/admin/yarn.lock'".
info If you think this is a bug, please open a bug report with the information provided in "/home/runner/work/admin/admin/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Process completed with exit code 1.
why could not access the project yarn.lock when using yarn command? why facing the permission issue in GitHub Actions? what should I do to fix this problem?
I also facing the similar issue with it, you should tried to use actions/setup-node like this to fix it:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
- run: npm install yarn -g
- name: Build React App
run: |
yarn
yarn global add umi
umi build

Publishing to Github Pages

I am currently working on setting up a workflow for my Github Pages site. I have successfully created html files from Python and now only need to publish. I am using this Github Action for doing that. However, my builds fail with the error message:
github-pages 222 | Error: No such file or directory # rb_check_realpath_internal - /github/workspace/bin/python3
I have the file /bin/python3 in my repository and it should additionally not be used for that build shouldnt it?
Why is it getting used and how do I fix it?
Note: I am not limited to this specific action. If there is another one that works better I would be happy to use it!
This is my worker file right now:
name: Jekyll site CI
on:
push:
branches: [ gh-pages ]
pull_request:
branches: [ gh-pages ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#v2.4.0
- name: install python
uses: actions/setup-python#v2
with:
python-version: "3.9.2"
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install jinja2
- name: run python script
run: python app.py
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages#v2.5.0
with:
build_dir: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

File pattern matching in GitHub actions run

I'm trying to automate upload of my NuGet package using GitHub actions. I was hoping I could match the file name which includes the version number to avoid having to hardcode it in the action YML. It works if I hardcode the file name. I guess I just need to understand the syntax to use file pattern match. See last line of that code sample:
name: .NET
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
defaults:
run:
working-directory: ./Project
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore SharpLibHid.sln
- name: Build debug
run: dotnet build SharpLibHid.sln --no-restore -c Debug
- name: Build release
run: dotnet build SharpLibHid.sln --no-restore -c Release
- name: Test
run: dotnet test SharpLibHid.sln --no-build --verbosity normal
- name: Publish Nuget
run: dotnet nuget push './Hid/bin/Release/SharpLibHid.*.nupkg' --skip-duplicate -k ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
How do you use file matching pattern in GitHub actions run?
Here is a successful build with hardcoded path:
https://github.com/Slion/SharpLibHid/actions/runs/998451423
Here is a failed build with my attempt at pattern matching:
https://github.com/Slion/SharpLibHid/actions/runs/998464157

Git push action is not working when pushing from git action container

I have an action on master branch which on push/merge builds a package, uploads it to PyPI then checks out to develop branch, bumps version in develop branch and pushes to the origin of develop branch. Develop branch has an action that listens to push/merge and does a snapshot release.
When I push to develop the develop action works perfectly and does a snapshot release, but when master branch pushes, push is successful but the action does not get triggered. What am I missing?
Both actions are added below.
name: Build and Upload Package to PyPI | Master Branch
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up Python
uses: actions/setup-python#v1
with:
python-version: '3.5'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install GitPython
pip install bumpversion
- name: Strip 'snapshot' from version
run: sed -i 's/-snapshot//g' setup.py
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_REPOSITORY_URL: https://pypi.domain.com
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Bump Verison and Push to develop
run: |
git stash
git config --local user.email "name#email.com"
git config --local user.name "username"
git checkout develop
python bump_version.py
cat .bumpversion.cfg
git remote set-url --push origin https://username:$GITHUB_TOKEN#github.com/repo/path
git push origin develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Build and Upload Package to PyPI | Develop Branch
on:
push:
branches:
- develop
jobs:
bumpTag_build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up Python
uses: actions/setup-python#v1
with:
python-version: '3.5'
- name: Install dependencies for setup
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_REPOSITORY_URL: https://pypi.domain.co,
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
Provided secrets.GITHUB_TOKEN is intentionally not allowed to trigger workflows. As seen in documention:
(...) if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
If you need your automagic push to be "visible" by workflows, you need to create Personal Access Token, add it to repo secrets, and use that instead of GITHUB_TOKEN.
Note that GitHub assumes that you know what you're doing, if you use non-stock token - which means preventing possible infinite loop is on you. While it's not a case in your scenario for now (develop branch does not push anything), it's worth to remember in case one of workflows will change some day.