-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (69 loc) · 3.71 KB
/
github-actions-workflow-file.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
name: GitHub Actions Demo
on:
#push:
#push was used to demonstrate what triggered the workflow in the last demo -- a push to Git
#if push: is uncommented, any push to this repo will trigger it, so it is commented out
#until we intend to have it run on a push to this repo.
#repository_dispatch is used to manually trigger the workflow
#when we have the type run_my_workflow. This is a custom made-up type shown in Neil's course .
repository_dispatch:
types: [run_my_workflow]
# workflow_dispatch: will make the Run Workflow button appear, this allows running
# manually within github.
workflow_dispatch:
jobs:
Example-Actions-Job:
name: Exploring GitHub Actions
runs-on: ubuntu-latest
steps:
# This code is for a later step using this file.
# The file is being referenced during a review of modules 2,3 and 4 of the course
# ${{}} is what tells github that this is an expression that needs to be evaluated,
# and not a string that needs to be printed.
# This github object is called a context: github.event.client_payload.mydata
# A context is a collection of properties about the environment or object that it represents.
# The line below is commented out until clip Demo External Triggers of module Exploring
# GitHub Actions Workflows
# *** 'run' operates the shell being used. ubuntu-latest will use Bash, the default Linux shell.
- run: echo "Payload field is ${{ github.event.client_payload.mydata}}"
# Display the event that tribgered the workflow
- run: echo "The job was triggered by a ${{ github.event_name }} event."
# Runner Information
- run: echo "This job is now running on a ${{ runner.os }} server hosted at GitHub."
# Information about the repository and branch
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
# Use action located in https://github.com/actions
- name: Check out repository code
# uses keyword tells github this is an action and where the code for it is stored
# it is in the actions repo and is checkout@v2
uses: actions/checkout@v2
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "Your repository has been copied to the path ${{ github.workspace }} on the runner."
- run: echo "The workflow is now ready to test your code on the runner."
- name: conditional step when event name is pull request
# here we use context information to make logical decisions
if: ${{ github.event_name == 'pull_request' }}
run: echo "This event is a pull request"
- name: List files in the repository
run:
ls ${{ github.workspace }}
- name: Setup dotnet on runner
uses: actions/setup-dotnet@v1
# params are passed to the runner using the with keyword
with:
dotnet-version: '3.x'
- name: Display dotnet version
run: dotnet --version
- run: echo "The preinstalled tools are located here on the runner ${{ runner.tool_cache }}."
- name: List files in tool cache
# each runner has certain tools preconfiged for a runner and these can be listed out.
run:
ls ${{ runner.tool_cache }}
# the job context gives us info about the current job.
- run: echo "This job's status is ${{ job.status }}"
Second-Job:
name: The second job runnong on another runner
runs-on: ubuntu-latest
needs: Example-Actions-Job
steps:
- run: echo "This job is now runnong on a ${{ runner.os }} server hosted by GitHub."