Scheduled Github action does not start - github

my cron jobs seems not to work. The file does not contain errors and works correctly in the push phase; however if I schedule the cron every 5 minutes, it never starts:
name: Deploy to Cloud Foundry Scheduled
on:
push:
branches: [ 'master' ]
pull_request:
schedule:
- cron: '*/5 * * * *'
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
# my steps here
Can you help me understand what I'm doing wrong?

Related

Scheduled run not running even though it was set up correctly?

I've added a schedule block to my pipeline that backs up my RDS database. This is the main yaml file for the pipeline, and yaml validator finds no errors. So why is it not running? Nothing shows up in Scheduled Runs section in the UI, and I actually waited 3 hours for it to run, to no avail. What am I missing?
name: $(Date:yyyyMMdd)$(Rev:.r)
variables:
- template: ../global-vars.yml
resources:
repositories:
- repository: self
type: git
name: Deployment
trigger: none
schedules:
- cron: "0 */3 * * *"
displayName: DB backup every 3 hours
branches:
include:
- master
always: true
stages:
- stage: DBBackup
displayName: DB Backup
jobs:
- template: /templates/db/backup.yml
There is no property schedules which can be placed in resources > repositories > repository according to YAML syntax documentation
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-repositories-repository?view=azure-pipelines
You can add schedules on the top level of YAML
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/schedules-cron?view=azure-pipelines
try something like this sample
name: $(Date:yyyyMMdd)$(Rev:.r)
variables:
- template: ../global-vars.yml
schedules:
- cron: "0 */3 * * *"
displayName: DB backup every 3 hours
branches:
include: master
always: true
resources:
repositories:
- repository: self
type: git
name: Deployment
trigger: none
stages: (...)

workflow_run is never trigged by pull_request

I have two very simple GitHub workflows for testing proposes. deploy-test-first which runs always on pull_request and deploy-test-second which should run on completion of deploy-test-first
The deploy-test-second however never runs. What Am I missing? How do I make it work?
name: deploy-test-first
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy-test-first:
runs-on: ubuntu-20.04
steps:
- name: deploy-test-first
run: echo 'deploy-test-first'
name: deploy-test-second
on:
workflow_run:
workflows: [deploy-test-first]
types: [completed]
branches: [develop]
jobs:
test-deploy-second:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-20.04
steps:
- name: test-deploy-second
run: echo 'deploy-test-second'
Both workflows are suppose to run on non-default branch develop in PR.

Invalid workflow file for GitHub actions

So I am just trying to learn how to use github workflow actions and made this simple starter test:
name: Basic test push
on:
push:
branches:
- 'autoupdate'
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo Test One Worked!
However, I get an error:
Invalid workflow file
You have an error in your yaml syntax on line 10'
Anyone know why?
You're indenting the steps, but it should be on the same level as runs-on:
name: Basic test push
on:
push:
branches:
- 'autoupdate'
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo Test One Worked!

workflow_run only on push

I have the following workflow:
name: ci
on:
push:
branches: [main, develop]
pull_request:
jobs:
....
name: deploy
on:
release:
types: [released]
workflow_run:
workflows: ["ci"]
branches: [develop]
types: [completed]
The problem I have is that when I create a PR from the develop to the main branch it also runs the deploy workflow. Is there any way to prevent this? and just run the deploy workflow on push after the CI finishes?
Thanks

Run particular jobs while creating pull request in githubactions

I have implemented ci/cd using GitHub actions. In ci/cd I have three jobs are there when I want to release a tag I want to build these three jobs and when I raise a pull request to a particular branch only two jobs should be executed for health check purposes. for example, I have a feature branch I want to merge this feature branch to the devel branch. when I raise a PR should be run only two jobs. how can I achieve this? below is my sample code.
name: CI
on:
pull_request:
branches:
- master
- devel
push:
tags:
- '*'
jobs:
build:
name: build
runs-on: self-hosted
steps:
--------------
deploy:
name: deploy
runs-on: self-hosted
steps:
------------
automation-test:
name: test
runs-on: self-hosted
steps:
------------
here when I raise a PR I want to run build and automation-test jobs.
You have two options here:
Have separate workflow files that run for the right branches.
Use conditionals in your job
The first option is likely the one you want. The only problem here is if the output from one job is used in another, but it doesn't sound like that's the case for you. I would recommend you simply break out your yaml workflows into two separate workflows:
name: CI
on:
pull_request:
branches:
- master
push:
tags:
- '*'
jobs:
build:
name: build
runs-on: self-hosted
steps:
--------------
deploy:
name: deploy
runs-on: self-hosted
steps:
------------
automation-test:
name: test
runs-on: self-hosted
steps:
------------
name: PR Builder
on:
pull_request:
branches:
- devel
jobs:
whatever_testing_jobs_you_like:
The second option might look something like this:
name: CI
on:
pull_request:
branches:
- master
push:
tags:
- '*'
jobs:
build:
name: build
runs-on: self-hosted
steps:
--------------
deploy:
if: "github.ref != devel" # you might tweak the condition based on your needs
name: deploy
runs-on: self-hosted
steps:
------------
automation-test:
name: test
runs-on: self-hosted
steps:
------------
These context values / conditions are well documented