When I run a GitHub Action for a feature branch, it reads all files from master instead of reading them from the feature branch

Viewed 22

I have a GitHub Action which is set to run at will when triggered manually (with the workflow_dispatch keyword under the on secton). Apparently when I run the Action from a feature branch, it only loads the Action YML from the feature branch and loads everything else from master.

One of the Action's steps calls a PowerShell script. When run for a feature branch, it executes the script that is in master, no the script in my feature branch. If it references a script that only exists in my feature branch and not in master, then it fails and says the script does not exist.

That makes it very hard to experiment with the Action, since apparently all its dependencies need to be merged to master before I can test them.

This is how I trigger my Action:

  1. Go to GitHub -> Actions -> Workflows sidebar and select my workflow.
  2. Next to where it says "This workflow has a workflow_dispatch event trigger", click Run workflow.
  3. Under Use workflow from, select my feature branch.
  4. Click Run workflow.

enter image description here

Am I doing something completely wrong here?

Here is my Action YML:

name: Deploy to persistent environment

on:
  workflow_dispatch:
    inputs:
      deployment_target:
        type: choice
        description: Choose an environment to deploy to
        options:
          - dev
          - staging
          - production

jobs:
  deploy-kms-to-persistent-environment:
    name: Deploy KMS to ${{ github.event.inputs.deployment_target}}
    runs-on: [self-hosted, 3shape-ubuntu-latest]

    steps:

    - name: Deploy application
      working-directory: ./src/deploy/kms-bicep
      shell: pwsh
      run: |
        ./deploy-release-application2.ps1
1 Answers

It turns out I need a checkout step in my Action: - uses: actions/checkout@v3

name: Deploy to persistent environment

on:
  workflow_dispatch:
    inputs:
      deployment_target:
        type: choice
        description: Choose an environment to deploy to
        options:
          - dev
          - staging
          - production

jobs:
  deploy-kms-to-persistent-environment:
    name: Deploy KMS to ${{ github.event.inputs.deployment_target}}
    runs-on: [self-hosted, 3shape-ubuntu-latest]

    steps:

    - uses: actions/checkout@v3

    - name: Deploy application
      working-directory: ./src/deploy/kms-bicep
      shell: pwsh
      run: |
        ./deploy-release-application2.ps1

Related