In Github Actions composite actions, you must specify the branch where the composite action is located, e.g.,
- uses: /username/repo-name/.github/composite-actions#main
Is there a way to specify the current branch instead rather than hardcode #main?
After checking further, it seems using the relative path works. For example:
- uses: ./.github/composite-actions
Related
Does anyone know what this does ?
uses: ./
I see it used in quite a few places but cannot seem to find any reference for it.
The uses keyword of github actions is used to specify the action that should be executed as part of a workflow. The ./ value tells GitHub to use the action defined in the current repository, rather than referencing a pre-built action.
It's also possible to specify the path to the action within the repository, rather than using ./. For example:
steps:
- uses: ./path
with:
parameter1: value1
parameter2: value2
This would execute the action located at ./path within the repository.
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'
name: Console
on:
push:
paths:
- "services/console/**"
- ".github/workflows/console.yaml"
pull_request:
paths:
- "services/console/**"
- ".github/workflows/console.yaml"
We have the above in the following file: .github/workflows/console.yaml. We have other files in the source code, an example would be in services/example-service/**.
The problem I'm trying to fix or understand is the above workflow is triggered when files in the services/example-service are changed and pushed or is in a pull request. This shouldn't happen because that directory is not stated in the on push paths or on pull_request paths.
Here is the documentation for this: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths
Is there some scenario I've not thought of regarding this or would this be considered a bug?
The only thing I can see that it might be is this: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#git-diff-comparisons
Note: If you push more than 1,000 commits, or if GitHub does not
generate the diff due to a timeout, the workflow will always run.
Our code has thousands of commits, but we do not push thousands of new commits when updating.
The reason was after contacting GitHub support was that pushes use two dot diffs while PRs use three dot diffs.
The two dot diff caused a trigger because we rebased the branch onto master which had changes to the directory stated and then we force pushed. This caused the diff between the new forced pushed branch and the immediate commit before on the branch to includes a hell of a lot of diffs, some of which were in the stated directroy.
Is there any way that a step in a workflow job can specify sub-steps to pass to a custom action?
steps:
- uses: ...
with:
steps:
- ...
- ...
- ...
For example, a uses: actions/cache#v2 will attempt to download a snapshot immediately (in the current step), and also inserts a post step to upload a fresh snapshot after all other steps in the parent job. This works well for build processes that (through multiple stages) intelligently recognise which objects need to be recreated and which do not. But it is not suited for workflows that need to set up a clean environment (or generate test data) that may then be manipulated by the tests. I'd like to make a different cache action, that is explicitly passed instructions for how to regenerate the cache from scratch, and which uploads the state before returning to the following step of the parent action.
Is there any way this could be achieved? (Composite actions? Advanced yaml syntax? Template expressions? Low-level actions toolkits/features? Implementing an interpreter to re-parse the input parameter?)
The Actions tab shows workflows created in main branche's /.github/workflows/ only
I have workflow.yml files with workflow_dispatch trigger that are defined in another branch (test) that are not yet merged into the main branch
Is there any way I can see and run workflows with workflow_dispatch trigger that are created in another branch not yet merged with the main branch?
It looks that you can't change at the moment. It takes actions from default branch. You can change default branch but I assume that this is not acceptable for you (which I understand). Please take a look here on github community -
Workflow files only picked up from master?
If you use a web browser, you will see a dropdown - Use workflow from
If you use GitHub CLI, you need to use --ref flag
gh.exe workflow run workflown_name --ref branch_name -f param_name=value
documentation is here