Reputation: 383
I have a working Github Action file that build on commits.
I want to be able to manually trigger a build so I only added "workflow_dispatch" and got the nice option button visible in the GUI where I can select which branch to manually build.
But when I select a branch ("dev") and start the build it always get skipped?!
The yml-file is both in my "main" branch and in the desired branch "dev"
My yml-file looks like below and "workflow_dispatch" is the only thing I have changed:
name: Build for dev
on:
workflow_dispatch:
push:
branches:
- dev
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- dev
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/[email protected]
with:
app_build_command: "npm run build-dev"
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_XXXXX }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "api" # Api source code path - optional
output_location: "dist" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/[email protected]
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_XXXXX }}
action: "close"
Does anyone know why build is being skipped, or where I can see the reason for it?
UPDATE: Screenshot from skipped build:
UPDATED! I found solution myself! I had an if statement in "build_and_deploy_job" so I needed to change it to:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
Upvotes: 7
Views: 4479
Reputation: 17369
I had the same symptom -- my manually run workflow was being marked as "Skipped."
In my case, I had the following condition on each job. This condition only ran the job if the previous workflow in the chain was successful:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
The above was not satisfied when the workflow was started manually. The following worked for me:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
The above says, "run this job if it was manually started or the parent workflow succeeded."
Upvotes: 7