惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
C
Check Point Blog
M
MIT News - Artificial intelligence
T
The Blog of Author Tim Ferriss
Jina AI
Jina AI
博客园 - 【当耐特】
U
Unit 42
月光博客
月光博客
腾讯CDC
Y
Y Combinator Blog
小众软件
小众软件
博客园_首页
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
T
Tailwind CSS Blog

Stories by Tomas Sirio on Medium

Turing Pi 2 Home cluster Hey There! Hello World! in ARM ISAs Make changes on Repository A while modifying Repository B? Github Actions is here Hello World! in ASM x86_64 How did I boost my productivity during quarantine
If statements on Github Actions
Tomas Sirio · 2020-11-11 · via Stories by Tomas Sirio on Medium

Tomas Sirio

Press enter or click to view image in full size

Hey there!

Last week I faced the need to have different steps to be run when Github Actions was executed. Today I brought you a simple solution to how I managed to achieve this. Be warned, the important content of this post will be the Github Actions Workflow.

Step by step:

We define a workflow that will be run on a ‘push’ event. We name this job ‘project-a-or-project-b’ and we assign it to a ubuntu container with the latest version possible.

Our main program only calculates a random number between 0 and 1. We could say it’s mostly a flip-coin program. If we get 0 we will run our ‘projectA’ program and if we get 1, we run ‘projectB’

Inside ‘projectA’ and ‘projectB’ there’s just a Print indicating which routine is being run

Our first step on the workflow is going to check-out the main repository in the ./mainRepository folder and then it will install go 1.9.3 in order to run the main program.

Once we get to the ‘Run Main Repository’ step, we assign it the id ‘main’ which will allow us later to get it’s outputs. So we define an output of the program:

and then we indicate Github Actions that the OUPUT variable is going to be an output on that step:

Now it’s time to know which side our coin landed on:

We can define an if statement on the steps that will depend on our OUTPUT from the last step. You can get your outputs concatenating the string ‘steps.{step_name}.outputs.{step_output}

That’s it for today. I’ll leave you the repo so you can check if you are missing something while trying it