I'm using this on: syntax to trigger a workflow when a file in a folder changes or a specific file changes. But for some reason, this is triggering also on any tag even though I tell it to a normal tags.
on:
push:
paths:
- '.cicd/**'
- '.github/workflows/cicd-sync.yaml'
- 'cicd.yaml'
After many attempts at this, I have found the solution to my issue.
Here is how we got it to work
push:
paths:
- '.cicd/**'
- '.github/workflows/cicd-sync.yaml'
- 'cicd.yaml'
branches:
- "**"
ignore-tags:
- '**'
Related
I'm quite a rookie with GitHub Actions so this might be a stupid question: Is there a way to link pull requests with issues (in the UI linked PRs are shown under Development) in Github Actions using Github CLI or octokit/rest.js via actions/github-script?
enter image description here
Background: there is a workflow that creates pull requests. That works fine, only thing missing is the link between issues and corresponding pull requests. I would prefer not to use keywords nor other custom actions from the marketplace.
I've searched in the octokit/rest.js documentation https://octokit.github.io/rest.js/v19 under Issues and Pulls as well as in the GitHub cli documentation https://cli.github.com/manual/gh but couldn't find a solution.
I would like to have a solution either using GitHub Script https://github.com/marketplace/actions/github-script
or the command line.
You can use the Add an issue link Action for that.
This Action allows linking issues to Pull Requests. For example:
name: 'Issue Links'
on:
pull_request:
types: [opened]
jobs:
issue-links:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: tkt-actions/add-issue-links#v1.8.1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}' # required
branch-prefix: 'issue-' # required
This workflow will trigger on Pull Request open and link related issues mentioned in the PR body.
Make sure to set the corresponding permission for the job:
permissions:
pull-requests: write
For more about these permissions visit the Permissions for the GITHUB_TOKEN.
I am trying to re-use a workflow in my GitHub repo and want to do something like this:
name: deploy
on:
push:
branches:
- 'dev'
- 'main'
jobs:
run-other-workflow:
uses: MyRepo/.github/workflows/some-other-workflow.yml#${{env.GITHUB_REF_NAME}}
I can't get this to work in any way that I am trying. Is this possible? Not being able to do this leads to duplicate templates.
EDIT:
Also tried:
jobs:
run-other-workflow:
uses: MyRepo/.github/workflows/some-other-workflow.yml#${{github.ref_name}}
I figured it out. The documentation uses the following example:
uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml#main
This implies that you need to reference an org and a repo. This also seems to lead to the requirement of adding #main or #v1.
However, you can also reference your repo without the org like so:
uses: ./.github/workflows/reusable-workflow.yml
If you do it like this adding an #ref is not required. This was not immediately clear from the documentation.
I can't for the life of me figure out why my GitHub Action isn't triggering on push. For context: I have a data file that is updated daily and pushed to the test branch with a timestamp commit message. I am trying to use this timestamp in a Dynamic Badge for my README. Everything works fine when the workflow is run manually (except, of course, I don't get the event data I am hoping to obtain when the action runs on the trigger.)
on:
push:
branches:
- test
paths:
- 'data/Sales.csv'
env:
BADGE_MESSAGE: ${{ github.event.commits[0].message }}
jobs:
create-badge-test:
runs-on: ubuntu-latest
steps:
- name: Create Dynamic Badge
uses: schneegans/dynamic-badges-action#v1.1.0
with:
auth: ${{ secrets.GIST_PAT }}
gistID: 0123456789 #Not actual gist ID
filename: test.json
label: Last Refresh
message: $BADGE_MESSAGE
color: orange
And yes, I've tried putting the branch name in quotes and updating the paths: to - '**.csv' and the action still does not trigger.
There must be something else wrong - all you have here in this workflows is just fine.
You can see it working here:
https://github.com/grzegorzkrukowski/stackoverflow_tests/actions/runs/1860382530
For this commit:
https://github.com/grzegorzkrukowski/stackoverflow_tests/commit/f3f8dd20fa780746441c7b6623b6a2a9929aa70d
It's exact copy of workflow from your question.
I would expect you are pushing a file with different name - keep in mind some systems will be case-sensitive - so pushing data/sales.csv won't work properly.
Another idea is that you pushing it to wrong branch or you have wrong path to the file.
You have to push to test branch and with data/Sales.csv - it only triggers workflow if both are true.
Short answers is - workflow is fine as it is - no brackets needed.
I could help more seeing the repository with this workflow and exact commits being done.
The action is not running because you also need to satisfy the paths condition as explained on GitHub docs
Note: If you use both the branches filter and the paths filter, the workflow will only run when both filters are satisfied.
If you want the action to run when you push to test you have to remove the paths condition
on:
push:
branches:
- 'test'
I have a project where I use GitHub Actions. I now need to ignore certain file changes inside certain folders. Here is my project structure:
masterDir
- contentDir
- dir1
- file1.ignore.md
- file2.md
- dir2
- file3.md
- file4.ignore.md
So I would like that my GitHub actions are not triggered for any changes to any file that has ignore.md in its file name. So here is what I came up with, but that does not seem to work.
on:
push:
paths-ignore:
- 'README.md'
- 'backup/**'
- 'masterDir/contentDir/**/*.draft.md'
Any ideas on what is wrong with my wildcard match?
It was indeed quite simple to do. All I have to do is the following:
on:
push:
paths-ignore:
- 'README.md'
- 'backup/**'
- '**/*.draft.md'
As a reference, here is the documentation in detail: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#patterns-to-match-file-paths
As it can be seen from the documentation that the wildcard matches any file in any folder that contains a .draft.md match.
My workflow file looks like this:
on:
push:
branches:
- master
paths:
- "src/*"
pull_request:
branches:
- master
paths:
- "src/*"
At some point i added the paths: "src/*" and it simply won't trigger (anymore)?
I tried different things such as the filter on branches/paths, but it's like github actions cannot do PR merge checks? I've set them up with other CI platforms just fine, but i can't get it working with github actions. I have read in some article that PR checks will not work if there is a merge conflict, but that is not the case here either
It might be because your PR is still opened.
As your workflow is implemented:
The PR event is only triggered on the initial PR.
The workflow is not triggered on subsequent pushes events to the branch that has PR (and is not master).