Skip to content

Commit 853b138

Browse files
authored
Ci/add-deploy-job (#12)
* fix(PD-12): update script version * ci(PD-12): add the environment name * ci(PD-12): remove name property * ci(PD-12): add deploy-to-production job * docs(PD-12): create readme
1 parent b69d901 commit 853b138

2 files changed

Lines changed: 110 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
- main
77
pull_request:
88
types: [synchronize]
9+
release:
10+
types: [created]
911

1012
jobs:
1113
unit-tests:
@@ -17,4 +19,16 @@ jobs:
1719

1820
- name: Run Tests
1921
run: |
20-
npm run test
22+
npm run test
23+
deploy-to-production:
24+
if: github.event_name == 'release'
25+
runs-on: ubuntu-latest
26+
environment: production
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Deploy Application
32+
run: |
33+
# Add commands here for deploying your application
34+
echo "Deploying application..."

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1-
# initialize-action
1+
# initialize-action
2+
3+
## Description
4+
5+
The **Initialize Action** sets up the environment for your workflow, cancels previous runs, and generates a project matrix for subsequent jobs. This action is designed to streamline your CI/CD pipeline by managing previous workflow executions and creating a dynamic project matrix based on changed files.
6+
7+
## Inputs
8+
9+
| Input | Description | Required | Default |
10+
|-------|-------------|----------|---------|
11+
| `project-root` | Project root folder | No | `.` |
12+
| `script-version` | Version of the script to use | No | `0.5.1` |
13+
14+
## Outputs
15+
16+
| Output | Description |
17+
|--------|-------------|
18+
| `matrix` | The project matrix for subsequent jobs |
19+
| `files` | List of changed files |
20+
21+
## Usage
22+
23+
```
24+
name: CI Workflow
25+
26+
on:
27+
push:
28+
branches:
29+
- main
30+
- develop
31+
32+
jobs:
33+
initialize:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Initialize Action
40+
uses: your-username/initialize-action@v0.1
41+
with:
42+
project-root: 'your/project/root'
43+
script-version: '0.5.1'
44+
45+
# Additional steps to use the outputs can go here
46+
```
47+
48+
## Steps
49+
50+
Steps
51+
1. **Cancel Previous Runs**: This step cancels any previous runs if the current branch is not `develop` or `main`.
52+
1. **Download Scripts**: The action downloads the specified version of the necessary scripts.
53+
1. **Unzip Scripts**: This step extracts the downloaded scripts from the zip file.
54+
1. **List Modified Files**: Uses the `tj-actions/changed-files` action to gather all modified files and processes them.
55+
1. **Set Dynamic Matrix**: This step generates a project matrix based on the modified files and outputs it for use in subsequent jobs.
56+
57+
## Example
58+
59+
Here's an example of how you can utilize the outputs of the Initialize Action in your workflow:
60+
61+
```
62+
name: Continuous Integration & Delivery
63+
64+
on:
65+
push:
66+
branches:
67+
- main
68+
pull_request:
69+
branches:
70+
- main
71+
72+
jobs:
73+
initialize:
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 15
76+
steps:
77+
- uses: actions/checkout@v4
78+
- name: initialize
79+
id: initialize
80+
uses: robaone/initialize-action@v0.3.7
81+
with:
82+
project-root: .
83+
script-version: 0.5.1
84+
outputs:
85+
matrix: ${{ steps.initialize.outputs.matrix }}
86+
unit-tests:
87+
needs: [initialize]
88+
strategy:
89+
matrix: ${{ fromJson(needs.initialize.outputs.matrix) }}
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 15
92+
steps:
93+
- uses: actions/checkout@v4
94+
```
95+

0 commit comments

Comments
 (0)