-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (130 loc) · 4.46 KB
/
00-firstworkflow.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: 00-first workflow
on:
push:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
type: string
default: 'dev'
input1:
description: 'Input 1'
type: string
default: 'efg'
input2:
description: 'Input 2'
type: number
default: 123
jobs:
job1:
runs-on: ubuntu-latest
env:
ENV_VAR1: 1234
ENV_VAR2: "abcd"
ENV_VAR3: ${{ github.event.inputs.input1 }}
ENV_VAR4: ${{ github.event.inputs.input2 }}
REPO_NAME1: ${{ github.repository }}
REPO_NAME2: ${GITHUB_REPOSITORY}
steps:
- name: Trigger
run: echo "Triggered by ${{ github.event_name }} event"
- name: Check Branch Input
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ -z "${{ github.event.inputs.branch }}" ]; then
echo "Branch input is required for manual trigger."
exit 1
else
BRANCH_NAME="${{ github.event.inputs.branch }}"
fi
else
# Extract branch name from github.ref
BRANCH_NAME="${{ github.ref }}"
BRANCH_NAME="${BRANCH_NAME##*/}" # This removes everything before the last '/'
fi
echo "Checkout branch $BRANCH_NAME"
- name: Verify directory1
run: |
echo "Repo root directory: $GITHUB_WORKSPACE"
echo "Current directory: $PWD"
echo "Cloned to: $(pwd)"
ls -la /home/runner/work/${{ github.event.repository.name }}
ls -la $GITHUB_WORKSPACE
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}
- name: Verify directory2
run: |
echo "Repo root directory: $GITHUB_WORKSPACE"
echo "Current directory: $PWD"
echo "Cloned to: $(pwd)"
echo "ls -la /home/runner/work/${{ github.event.repository.name }}:"
ls -la /home/runner/work/${{ github.event.repository.name }}
echo "ls -la $GITHUB_WORKSPACE"
ls -la $GITHUB_WORKSPACE
- name: Move to custom workspace
run: |
mv "$GITHUB_WORKSPACE"/* "$(dirname "$GITHUB_WORKSPACE")"
#rm -rf "$GITHUB_WORKSPACE" # Delete the empty folder
echo "Current directory: $PWD"
cd ..
tree "$(pwd)"
echo "Current directory: $PWD"
- name: Verify directory3
run: |
echo "Current directory: $PWD"
echo "Cloned to: $(pwd)"
echo "ls -la /home/runner/work/${{ github.event.repository.name }}:"
ls -la /home/runner/work/${{ github.event.repository.name }}
- name: Log Current Branch and Commit
run: |
echo ${GITHUB_REPOSITORY##*/}
echo "REPO_NAME1=$REPO_NAME1"
echo "REPO_NAME2=$REPO_NAME2"
REPO_NAME1=${REPO_NAME1##*/}
REPO_NAME1=${REPO_NAME1##*/}
echo "REPO_NAME1=extension/$REPO_NAME1"
echo "REPO_NAME1=extension/${REPO_NAME1}"
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Current commit: $(git rev-parse HEAD)"
- name: Create output
run: |
echo "This job is running on Ubuntu!"
mkdir -p ${{ github.workspace }}/output/child_folder1/test2
echo "Hello from Job 1" > output/child_folder1/test2/message.txt
ls -R
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: job1-output
path: ./output
job2:
runs-on: windows-latest
needs: job1
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log Current Branch and Commit
run: |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Current commit: $(git rev-parse HEAD)"
dir
cd test_folder
- name: Download output from Job 1
uses: actions/download-artifact@v3
with:
name: job1-output
- name: Run on Windows
run: |
echo "This job is running on Windows!"
dir
type job1-output\message.txt
echo "Output folder"
dir child_folder1
move child_folder1\* ..
echo "List folder"
dir