generated from robomics/2022-sbi-ci-workshop-pt1
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (59 loc) · 1.95 KB
/
002_multiple_jobs_v3.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: 002 - Multiple jobs v3
on:
push:
branches: [ main, gha-devel ]
paths: [ ".github/workflows/002*v3.yml" ]
jobs:
# Define job #1
first-job:
runs-on: ubuntu-latest
steps:
- name: Sleep for a while
run: sleep 5
- name: What time is it?
run: |
# Write current time to file "message.txt"
printf 'Job #1: time is ' > message.txt
date >> message.txt
- name: Print message
run: cat message.txt
- name: Save message
# Use an action written by the community
uses: actions/upload-artifact@v3
# Specify parameters for the action
# Documentation: https://github.com/actions/upload-artifact/blob/main/action.yml
with:
name: output-message # TODO: give a name to this artifact (mandatory option)
path: message.txt # Mandatory option
if-no-files-found: error
retention-days: 1
# Define job #2
second-job:
runs-on: ubuntu-latest
needs: first-job # TODO: make second-job run after first-job
steps:
- name: Sleep for a while
run: sleep 5
- name: What time is it?
run: |
printf 'Job #2: time is '
date
- name: Download message from Job N°1
uses: actions/upload-artifact@v3
# TODO: use the actions/download-artifact@v3 action to restore the artifact in second-job
# docs: https://github.com/actions/download-artifact#usage
with:
name: output-message # TODO: specify the name of the artifact to be restored
path: message.txt
- name: Ensure message.txt exists
# Useful for debugging
run: |
pwd
ls -lah .
ls -lah message.txt
- name: Print message from Job N°1
run: |
# Make sure the message came from Job #1
grep --quiet '^Job #1:' message.txt
# Print message
cat message.txt