forked from cloudquery/cloudquery
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (163 loc) · 6.4 KB
/
source_hackernews.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
165
166
167
168
169
170
171
name: Source Plugin Hacker News Workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
paths:
- "plugins/source/hackernews/**"
- ".github/workflows/source_hackernews.yml"
push:
branches:
- main
paths:
- "plugins/source/hackernews/**"
- ".github/workflows/source_hackernews.yml"
jobs:
plugins-source-hackernews:
timeout-minutes: 30
name: "plugins/source/hackernews"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./plugins/source/hackernews
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: plugins/source/hackernews/go.mod
cache: true
cache-dependency-path: plugins/source/hackernews/go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
working-directory: plugins/source/hackernews
args: "--config ../../.golangci.yml"
- name: Setup CloudQuery
if: github.event_name == 'pull_request'
uses: cloudquery/setup-cloudquery@v4
with:
version: v6.5.0
- name: gen
if: github.event_name == 'pull_request'
run: make gen
- name: Fail if generation updated files
if: github.event_name == 'pull_request'
run: test "$(git status -s | wc -l)" -eq 0 || (git status -s; exit 1)
- name: Build
run: go build .
- name: Test
run: make test
validate-config-ui:
timeout-minutes: 15
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./plugins/source/hackernews
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: plugins/source/hackernews/go.mod
cache: true
cache-dependency-path: plugins/source/hackernews/go.sum
- name: Setup CloudQuery
uses: cloudquery/setup-cloudquery@v4
with:
version: v6.5.0
- name: Build
run: go build .
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: "npm"
cache-dependency-path: "plugins/source/hackernews/cloud-config-ui/package-lock.json"
- name: Install dependencies
working-directory: "plugins/source/hackernews/cloud-config-ui"
run: npm ci
- name: Install dotenv
run: npm install dotenv-cli -g
- name: Install Playwright
working-directory: "plugins/source/hackernews/cloud-config-ui"
run: npx playwright install --with-deps
- name: Build config UI
working-directory: "plugins/source/hackernews/cloud-config-ui"
env:
REACT_APP_PLUGIN_TEAM: cloudquery
REACT_APP_PLUGIN_KIND: source
REACT_APP_PLUGIN_NAME: hackernews
REACT_APP_PLUGIN_VERSION: development
run: |
REACT_APP_USE_CLOUD_APP_MOCK=true npm run build
- name: Run E2E tests and generate configs
working-directory: "plugins/source/hackernews/cloud-config-ui"
run: E2E_TESTS_GENERATE_CONFIG=true npm run test:e2e
deploy:
if: github.event.action != 'closed' && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'release')
runs-on: ubuntu-latest
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
defaults:
run:
working-directory: ./plugins/source/hackernews/cloud-config-ui
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-deploy
cancel-in-progress: false # to make sure that old Vercel deployments are deleted
steps:
- uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install -g vercel
- name: Deploy to Vercel
run: |
DEPLOYMENT_URL=$(vercel --token $VERCEL_TOKEN)
echo "Deployed to: $DEPLOYMENT_URL"
echo "DEPLOYMENT_URL=$DEPLOYMENT_URL" >> $GITHUB_ENV
ALIAS_DEPLOYMENT_BASE_URL=plugin-source-hackernews-cloud-ui-${{ github.event.pull_request.number }}.vercel.app
ALIAS_DEPLOYMENT_URL=https://$ALIAS_DEPLOYMENT_BASE_URL
vercel --token $VERCEL_TOKEN --scope $VERCEL_ORG_ID alias $DEPLOYMENT_URL $ALIAS_DEPLOYMENT_BASE_URL
echo "Alias deployed to: $ALIAS_DEPLOYMENT_URL"
echo "ALIAS_DEPLOYMENT_URL=$ALIAS_DEPLOYMENT_URL" >> $GITHUB_ENV
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
token: ${{ secrets.GH_CQ_BOT }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: "cq-bot"
body-includes: "Hacker News Cloud UI deployed to Vercel:"
- name: Delete Previous Vercel Deployment (if comment with URL exists)
if: steps.find-comment.outputs.comment-id != ''
run: |
echo "Comment found:"
echo "${{ steps.find-comment.outputs.comment-body }}"
PREVIOUS_DEPLOYMENT_URL=$(echo "${{ steps.find-comment.outputs.comment-body }}" | awk '/Unique Vercel deployment URL:/ {getline; print $1}')
echo "Previous deployment URL: $PREVIOUS_DEPLOYMENT_URL"
if vercel rm "$PREVIOUS_DEPLOYMENT_URL" --token $VERCEL_TOKEN --scope $VERCEL_ORG_ID --yes; then
echo "Deployment $PREVIOUS_DEPLOYMENT_URL was successfully deleted."
else
echo "Failed to delete deployment $PREVIOUS_DEPLOYMENT_URL. It may not exist or there was an error."
fi
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GH_CQ_BOT }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
🚀 Hacker News Cloud UI deployed to Vercel:
${{ env.ALIAS_DEPLOYMENT_URL }}
You can also check out this plugin in action at:
https://cloud.cloudquery.io/teams/cloudquery-test/sources/create?plugin-cloud-ui=cloudquery|source|hackernews|${{ env.ALIAS_DEPLOYMENT_URL }}
Unique Vercel deployment URL:
${{ env.DEPLOYMENT_URL }}
edit-mode: replace