GitHub triggers pull_request but it is not expected - github-actions

I have a workflow, main.yml:
name: Build Main
on:
push:
branches: main
pull_request:
branches:
- main
types: [opened, synchronize, reopened, labeled]
I also have this other one, feature.yml:
name: Build Feature
on:
push:
branches: feature/**
When I'm on a feature branch (feature/NN-my-feature), and I push a commit from Visual Studio Code, both the workflows run.
Looking at the Actions in GitHub, the main.yml is triggered by a "pull_request".
I don't understand why/how the pull_request on "main" is triggered.

Related

Github Action workflow_run only on push to main branch

I have a CI workflow that runs on PR and PUSH to main branch.
---
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
I have another workflow I'd like to only run after CI is complete and conclusion is success but only when it's pushed to main branch.
---
name: Build
on:
workflow_run:
workflows: ["CI"]
types:
- completed
jobs:
build:
name: Build
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
It runs on both PR and push to main. How do I get the Build workflow to only run on push to main?
It looks like you can just filter on the branch in the Build workflow (see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#limiting-your-workflow-to-run-based-on-branches):
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main

Why will this not trigger on a pull request push commit update?

name: blabla bacon n eggs
on:
pull_request:
branches:
- basickarl/gh-actions-pr
defaults:
run:
shell: bash
jobs:
somting:
runs-on: ubuntu-latest
steps:
- run: echo "testy"
I have pushed my code on the branch stated to the origin repo in github. I have created a pull request. I updated some code on the branch and pushed, but the actions is not triggering? How does one trigger a github action workflow when updating a pull request?
The updates to the branch I am making is the workflow file itself.
Here is an example repo: https://github.com/basickarl/github-actions/actions/workflows/test.yaml
For some reason only on: [pull_request] seems to work.
Use types: [synchronize] under on: pull-request:

Github action manual execution not working

I have 3 different workflows in a project configured at top as:
plan_streamline.yml
name: plan
on:
push:
branches:
- main
workflow_dispatch:
...
terrform_import.yml
name: terraform_import
on: workflow_dispatch
...
plan.yml
on:
push:
branches:
- main
workflow_dispatch:
But within the github action I do not see the ability to manually execute any of the workflows, as I should be seeing something like https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
What is wrong with my workflow configuration?
Merged the branch with the new workflows to the default branch so that option appears now

Github actions triggers the wrong workflow as status checks on PR creation

I have two workflows. They have the following:
my-prod-ci
on:
pull_request:
branches:
- master
jobs:
myjob:
my-dev-ci
on:
pull_request:
branches:
- develop
jobs:
myjob:
The status checks in the repo is set to use myjob
When I create a PR from feature branch to develop branch, both the workflows are run. I only want my-dev-ci to run.
Similarly on creating a PR from develop to master branch, both workflows are run. I only want my-prod-ci to run.
Am I missing something?
Checking out the GitHub workflow syntax, I would try and add explicit branches pattern directives:
Example:
on:
pull_request:
branches:
- 'master'
- '!feature'
jobs:
myjob:

Trigger GitHub Action Workflow By Pull Request

I'd like to trigger automatically a GitHub Action Workflow for each [assigned, opened, synchronize, reopened] Git Pull Request from side-branch into master.
In addition, Is there a way to checkout the code from the private repository of a PR via branch name?
Below you can find my GitHub Action workflow that I've tried but unfortunately when I open a PR from side-branch into master it didn't trigger at all.
on:
workflow_dispatch:
pull_request:
types: [assigned, opened, synchronize, reopened]
branches:
- master
jobs:
build-image:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
with:
ref: ${{github.event.pull_request.head.sha}}
Is it possible, how can I do that?