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

推荐订阅源

Y
Y Combinator Blog
IT之家
IT之家
博客园_首页
量子位
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
博客园 - 聂微东
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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