-
Notifications
You must be signed in to change notification settings - Fork 41
108 lines (86 loc) · 3.32 KB
/
pr-cleanup.yaml
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
name: PR Cleanup
on:
pull_request:
types:
- closed
jobs:
clean-up-pr-caches:
name: Clean Up PR Caches
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Clean Up
run: |
gh extension install actions/gh-actions-cache
set -o pipefail
set -o errexit
gh cache list --repo="${{ github.repository }}" \
--limit=2000 \
--json='key,id,ref' \
--jq='.[] | select(.ref == "refs/pull/${{ github.event.pull_request.number }}/merge") | .id' \
| xargs --verbose --max-args=1 gh cache --repo="${{ github.repository }}" delete
clean-up-hosted-datasets:
name: 'Clean Up Hosted Datasets'
runs-on: ubuntu-latest
env:
GCP_PROJECT_ID: glaredb-dev-playground
SNOWFLAKE_USERNAME: ${{ secrets.SNOWFLAKE_USERNAME }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON }}
- name: Setup snowsql
run: |
curl -o snowsql.bash \
https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.24-linux_x86_64.bash
mkdir -p ~/bin
SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql.bash
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
- name: Cleanup (Snowflake)
run: |
export PATH="$HOME/bin:$PATH"
./scripts/cleanup-snowflake-dataset.sh ${{ github.event.pull_request.head.ref }}
- name: Cleanup (BigQuery)
run: ./scripts/cleanup-bigquery-dataset.sh ${{ github.event.pull_request.head.ref }}
update-main-datasets:
name: 'Update main Datasets'
runs-on: ubuntu-latest
# Only update if PR is actually merged
if: github.event.pull_request.merged == true
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON }}
GCP_PROJECT_ID: glaredb-artifacts
SNOWFLAKE_USERNAME: ${{ secrets.SNOWFLAKE_USERNAME }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
# Set this so the main database is updated.
BIGQUERY_USE_MAIN_DATASET: true
SNOWFLAKE_USE_MAIN_DATABASE: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON }}
- name: Setup snowsql
run: |
curl -o snowsql.bash \
https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.24-linux_x86_64.bash
mkdir -p ~/bin
SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql.bash
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
- name: Download testdata from GCS
run: ./scripts/prepare-testdata.sh
- name: Update main dataset (Snowflake)
run: |
export PATH="$HOME/bin:$PATH"
./scripts/create-test-snowflake-db.sh
- name: Update main dataset (BigQuery)
run: ./scripts/create-test-bigquery-db.sh