-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathGHCopilotProjects_Zip_Code_Ex7.yml
More file actions
80 lines (73 loc) · 3.22 KB
/
GHCopilotProjects_Zip_Code_Ex7.yml
File metadata and controls
80 lines (73 loc) · 3.22 KB
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
# This workflow is triggered on two events: workflow_dispatch and push.
#
# - The workflow_dispatch event allows you to manually trigger the workflow from GitHub's UI.
# - The push event triggers the workflow whenever there's a push to the master branch, but only
# if the changes include files in the LearnModuleExercises/SampleApps/** directory.
#
# The defaults section sets the default shell for all run commands in the workflow to PowerShell (pwsh).
#
# The workflow consists of a single job named create_zip, which runs on the latest version of Ubuntu.
#
# This job has three steps:
#
# 1. The Checkout step uses the actions/checkout@v4 action to checkout the repository's code onto the
# runner. This is a common first step in most workflows as it allows subsequent steps to operate on
# the codebase.
#
# 2. The Create SampleApps zip step changes the current directory to ./LearnModuleExercises/SampleApps
# and then creates a zip file of all the files in that directory, including those in the .vscode
# subdirectory. The -r option is used to zip directories recursively and the -q option is used to run
# the command quietly without printing a lot of output. The resulting zip file is saved in the
# ../Downloads directory with the name SampleApps.zip.
#
# 3. The Commit and push step uses the Endbug/add-and-commit@v7 action to add the newly created zip file
# to the repository, commit the changes with the message 'Updating Zip for API source files', and then
# push the changes back to the repository. The add input is set to the path of the zip file and the push
# input is set to true to enable pushing.
#
# This workflow is useful for automatically packaging and versioning sample applications whenever changes
# are made to them.
#
name: CreateGHCopilotEx7SamplesZip
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- DownloadableCodeProjects/standalone-lab-projects/consolidate-duplicate-code/**
defaults:
run:
shell: bash
jobs:
create_zip:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create GHCopilotEx7 SampleApps zip
run: |
# Ensure Downloads directory exists
mkdir -p ./DownloadableCodeProjects/Downloads
# Change to source directory
cd ./DownloadableCodeProjects/standalone-lab-projects/consolidate-duplicate-code
# Check if there are any git-tracked files to zip
if [ -z "$(git ls-files)" ]; then
echo "No git-tracked files found in the source directory"
exit 1
fi
# Remove existing zip file and create new one
rm -f ../../Downloads/GHCopilotEx7LabApps.zip
zip -r -q ../../Downloads/GHCopilotEx7LabApps.zip $(git ls-files)
# Verify zip file was created
if [ ! -f ../../Downloads/GHCopilotEx7LabApps.zip ]; then
echo "Failed to create zip file"
exit 1
fi
echo "Successfully created GHCopilotEx7LabApps.zip"
- name: Commit and push
uses: Endbug/add-and-commit@v7
with:
add: '["DownloadableCodeProjects/Downloads/GHCopilotEx7LabApps.zip"]'
message: 'Updating Zip with sample app source files'
push: true