forked from swimlane/ngx-datatable
-
Notifications
You must be signed in to change notification settings - Fork 24
164 lines (136 loc) · 4.58 KB
/
test_and_deploy.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Build, Test, and Deploy
on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- master
jobs:
check-rebase:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history is fetched
- name: Add upstream remote
run: |
# Add the upstream repository (base repo)
echo "Adding upstream remote..."
git remote add upstream https://github.com/siemens/ngx-datatable.git
git fetch upstream
echo "Upstream remote added and fetched."
- name: Fetch PR Branch from Fork
run: |
echo "Fetching PR branch from fork..."
git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.head_ref }}
echo "Fetched PR branch: ${{ github.head_ref }}"
- name: Attach to PR Branch
run: |
echo "Checking out the PR branch: ${{ github.head_ref }}"
git checkout ${{ github.head_ref }}
echo "Checked out branch: ${{ github.head_ref }}"
- name: Fetch the latest upstream master (or main) branch
run: |
echo "Fetching latest master from upstream..."
git fetch upstream master # or main if that's your default branch
echo "Fetched latest master branch from upstream."
- name: Verify PR and Upstream master State
run: |
UPSTREAM=master # Use 'main' if your default branch is named 'main'
echo "Target upstream branch: $UPSTREAM"
CURRENT=$(git rev-parse HEAD)
MERGED=$(git merge-base HEAD upstream/$UPSTREAM)
echo "Current commit hash: $CURRENT"
echo "Merged commit hash: $MERGED"
# Check if the branch is rebased or not
if [ "$MERGED" != "$CURRENT" ]; then
echo "This branch is not rebased with the latest $UPSTREAM."
echo "Run 'git rebase upstream/$UPSTREAM' locally to fix this."
exit 1
else
echo "Branch is up-to-date with $UPSTREAM."
fi
build:
needs: check-rebase
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Node Version
uses: actions/setup-node@v4
with:
node-version: lts/iron
- name: Set the branch name
id: set_branch
run: |
BRANCH_NAME=${{ github.head_ref }}
echo "Branch name is: $BRANCH_NAME"
# Check for remote branch
REMOTE_BRANCH=$(git ls-remote --heads https://[email protected]/chintankavathia/ngx-datatable-snapshots.git $BRANCH_NAME)
echo "Remote branch lookup result: $REMOTE_BRANCH"
if [ -n "$REMOTE_BRANCH" ]; then
echo "Branch $BRANCH_NAME exists"
echo "branch=$BRANCH_NAME" >> $GITHUB_ENV
else
echo "Branch $BRANCH_NAME does not exist, defaulting to main"
echo "branch=main" >> $GITHUB_ENV
fi
- name: Clone Snapshot Repository
run: |
git clone https://[email protected]/chintankavathia/ngx-datatable-snapshots.git temp_snapshots
cd temp_snapshots
git checkout ${{ env.branch }}
env:
SNAPSHOT_REPO_TOKEN: ${{ secrets.SNAPSHOT_REPO_TOKEN }}
- name: Copy Snapshots to Playwright Folder
run: |
mkdir -p playwright/snapshots
cp -r temp_snapshots/snapshots/e2e playwright/snapshots/
rm -rf temp_snapshots
- name: Install
uses: bahmutov/npm-install@v1
- name: Build and package library
run: |
npm run package --if-present
env:
CI: true
- name: Format
run: |
npm run format:check --if-present
env:
CI: true
- name: Build
run: |
npm run build --if-present
env:
CI: true
- name: Test
run: |
npm run ci --if-present
env:
CI: true
- name: E2E Prepare
run: |
npm run e2e:prepare --if-present
env:
CI: true
- name: E2E
run: |
npm run vrt --if-present
env:
CI: true
- name: Build Docs
run: |
npm run build-docs --if-present
env:
CI: true
- name: Deploy Docs
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: dist/ngx-datatable
if: ${{ github.ref == 'refs/heads/master' }}