How to run a github action from command line - github

I need to run some Github action on my repository,
but the Web-UI gives me some trouble with branch selection.
How can i run action by command line?

The Github Command Line tool has many options for managing actions.
to run a workflow, simply run gh workflow run which will let you interactively select the workflow and fill in parameters.
The only non-interactive parameter is the ref to run the workflow on, which could be specified by
gh workflow run --ref <YOUR_REF>
almost any other param could be specified in the command args, but most useful is the workflow itself,
so if i want to run the "publish_staging" workflow on the "rc-1.3.5" branch, i can just run
gh workflow run publish_staging.yml --ref rc.1.3.5

Related

Automatically update generated fish scripts (completions, etc)

Let's say I have a completions scripts generated by gh completion -s fish and saved to an appropriate location. The question is: how do I update the script automatically on gh updates? Is there a plugin or should I do some scripting?
If gh completion -s fish is fast, you can just run it as the script that loads completions. Create a ~/.config/fish/completions/gh.fish with the following contents:
gh completion -s fish | source
Then it will be run on first load in each shell instance, though it won't reload during the lifetime of that instance.
Alternatively, you could set up a scheduled task (eg cron) or trigger depending on the operating system you are using.

How to schedule the execution of a Python script in Azure DevOps (after successful Build)?

I have an Azure Pipeline Build. The *.yaml file executes correctly a Python script (PythonScript#0). This script itself creates (if does not exist), executes and publishes Azure ML pipeline. It runs well when the Build is executed manually or is triggered by commits.
But I want to schedule the automated execution of the ML pipeline (Python script) on a daily basis.
I tried the following approach:
pipeline_id = published_pipeline.id
recurrence = ScheduleRecurrence(frequency="Day", interval=1)
recurring_schedule = Schedule.create(ws,
name=<schedule_name>,
description="Title",
pipeline_id=pipeline_id,
experiment_name=<experiment_name>,
recurrence=recurrence)
In this case the pipeline runs during 3-4 seconds and terminates successfully. However, the Python script is not executed.
Also, I tried to schedule the execution of a pipeline using Build, but I assume that it is a wrong approach. It rebuilds a pipeline, but I need to execute a previously published pipeline.
schedules:
- cron: "0 0 * * *"
displayName: Daily build
always: true
How can I execute my published pipeline daily? Should I use Release (which agents, which tasks?)?
Also, I tried to schedule the execution of a pipeline using Build, but
I assume that it is a wrong approach. It rebuilds a pipeline, but I
need to execute a previously published pipeline.
Assuming your python-related task runs after many other tasks, then it's not recommended to simply schedule the whole build pipeline, it will rerun the pipeline(other tasks+python script).
Only the pipeline can be scheduled the instead of tasks, so I suggest you can create a new build pipeline to run the python script. Also, a private agent is more suitable for this scenario.
Now we get two pipelines: Original A and B which used to run the python script.
Set B's build completion to be A, so that if A builds successfully the first time, B will run after that.
Add a command-line task or PS task as pipeline A's last task. This task(modify the yml and then push the change) will be responsible for updating the B's corresponding xx.yml file to schedule B.
In this way, if A(other tasks) builds successfully, B(pipeline to run python script) will execute. And B will run daily after that successful build.
Hope it helps and if I misunderstand anything, feel free to correct me.

Setting up Build Pipeline for Azure Bot Service/Azure Functions solution in VSTS Build

I have an Azure bot service solution, which is in my VSTS Git repository.
I am using Task Runner in visual studio to compile, run and debug code on my local machine.
Similarly, I want to build and compile the code in my VSTS build pipeline, like how we do build using Visual Studio template for .Net applications
I am very new to Bot service projects where it having C# Script files.
I have seen msdn documents all are mentioned Continuous Integration where it will directly link to my Git repo branch. Whenever I commit code it automatically push to My Azure Bot Service, here I want to make sure the code I commit should be compile before push to Azure Bot service. For that I want to setup a Build pipeline.
Can anyone know how to setup a build pipeline for this kind of projects which having C# Script files?
UPDATE:
In my local PC I have installed Azure Functions CLI tools, and Command Task Runner extension to visual studio. I followed the below link to enable debugging locally
enter link description here
Task runner running debughost.cmd file which is in my Bot Service code, it contains the following code
#echo off
set size=0
call func settings list -data > %temp%\settings-list
call :filesize %temp%\settings-list
if NOT %size% == 0 goto show
#echo ----------------------------------------------------------------------
#echo To fetch your bot service settings run the following command:
#echo func azure functionapp fetch-app-settings [YOUR_BOT_SERVICE_NAME]
#echo func azure functionapp fetch-app-settings AthenaDevbvpn6xsu2tz6i
#echo ----------------------------------------------------------------------
goto start
:show
type %temp%\settings-list
erase %temp%\settings-list
:start
#func host start -p 3978
goto :eof
:filesize
set size=%~z1
exit /b 0
Output in task runner is
There isn't any out of box task to compile CSX file for now. Following is the workaround I can think for your scenario but which is not perfect:
Deploy your own build agent and then configure it by following the steps in the link you provided: Debugging C# bots built using the Azure Bot Service on Windows.
Create a powershell script to call the Azure Function CLI to compile the csx file like the "debughost.cmd" did and check if there is any error occur during the compilation.
Upload the powershell script into the source control.
Add a powershell script task in your build definition to call the powershell script you created.
Save and queue the build definition.
Here is the powershell script I created for your reference:
##Run Azure Func command to compile csx file
$compile = Start-Process 'func' -passthru -WorkingDirectory '.' -ArgumentList 'host start -p 3739' -RedirectStandardOutput 'output.txt'
##You need to set the sleep time base on the build time of your project
Start-Sleep -s 20
Stop-Process $compile -Force
Stop-Process -Name 'Func'
##Get the output from Func and check if there is error in the output
$boutput = Get-Content 'output.txt'
Write-Host 'Azure Function CLI Log:'
Write-Host '*****************************************************************************************************************************'
$boutput
Write-Host '*****************************************************************************************************************************'
$reg = "Function.compilation.error"
foreach($line in $boutput){
if($line -match $reg)
{
##Fail the task if function compilation error exist
Write-Host '##vso[task.logissue type=error]Error occur during function compilation'
Exit 1
}
}
Write-Host 'Function compilation success!'
And you will get this result if the compilation failed:
For Azure Bot Service, set continuous integration with master branch of your repository in VSTS, for repository in VSTS, you can create a new branch, such as Dev, then do work with Dev branch and merge to master. After that the code will be updated to azure.
Simple Steps:
Set continuous integration to your repository (master branch) in VSTS
Go to Code page of your repository in VSTS
Select Branches
Click New branch (e.g. dev)
Clone dev branch to your local and work with it (e.g. modify)
Push changes to remote Dev branch
Create a build definition
Enable Allow Scripts to Access OAuth Token option in Options tab.
Add a step to build app (e.g. gulp) according how do you build in local
Add Command Line step
Add Command Line step
Add Command Line step

Merge code into a different branch at the end of BuildBot steps

I have a buildbot setup which is able to checkout code from branch "a" and able to run a bunch of build, test commands on that code. While this works, now I want the code to be merged into branch "b" when all of the steps are successfully finished.
Is there a way in buildbot to do that?
On all CI systems, there is always the option to drop down to the command line - in buildbot, you can use the ShellCommand for that, e.g.:
f = BuildFactory()
f.addStep(ShellCommand(
command=['make', 'test'], haltOnFailure=True))
f.addStep(ShellCommand(
command=['git', 'merge', ...])
haltOnFailure ensures that the merge is only run when the tests have passed.
P.S.: of course, it's enough to use the ShellCommand for the merge step, the prior step(s) can be anything, as the haltOnFailure is a common option to all steps.

How to execute commandline application (bat) before mercurial commit?

I would like to execute command line application before each commit (push) to central repository. If application will execute with errors, commit should fail with some message.
I have found some examples of python hooks, but nothing about calling bats or exe.
You just put the exe/batch file as the command for the hook (you probably dont need the bat and exe extensions):
[hooks]
pre-commit.example1 = /path/to/somebatfile.bat
pre-commit.example2 = /path/to/someexefile.exe