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

推荐订阅源

N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
IT之家
IT之家
腾讯CDC
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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