-
Notifications
You must be signed in to change notification settings - Fork 7
91 lines (80 loc) · 2.85 KB
/
ci.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
name: CI Workflow for API Integration Testing
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
# Add timestamp
print_timestamp:
runs-on: ubuntu-latest
steps:
- name: Generate timestamp
run: |
echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Print timestamp
run: |
echo "Execution time (Pacific Time Zone) $TIMESTAMP"
test-and-publish:
needs: print_timestamp
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Lint
run: pnpm eslint .
# Ensure you have a lint script in your package.json
- name: Run Tests
continue-on-error: true
run: |
echo "Load environment variables"
export API_BASE_URL=${{ secrets.API_BASE_URL }}
export API_PREFIX=${{ secrets.API_PREFIX }}
export API_KEY=${{ secrets.API_KEY }}
pnpm exec playwright test
- name: Push Slack Notification
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID_GITHUB_NOTIFICATION }}
payload: |
{
"text": "${{ github.repository }}: API Integration Tests have been completed. Check the results at github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"blocks": [
{ "type": "divider" },
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Playwright Test Results"
},
"image_url": "http://www.quickmeme.com/img/b9/b9848df257b95cd39585368475a4b4e4a3a8c774f7390226daecb79b912087ad.jpg",
"alt_text": "Playwright Test Results"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text":"${{ github.repository }}: API Integration Tests have been completed. \nCheck the results at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- name: Upload Test Results
uses: actions/upload-artifact@v2
# if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
name: test-results
path: ./playwright-report/index.html