-
Notifications
You must be signed in to change notification settings - Fork 16
116 lines (101 loc) · 4.53 KB
/
refresh-test-credentials.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
# We need to push credentials into github that have no actual permissions for
# anything. However, just in case those credentials expire every hour we do this
# by having a GCP project where service account keys expire every hour. This is
# done to allow for CI to run some jobs that need a GCP Service Account but
# actually don't need access to run. This will allow us to use some checks with
# contributors without write access to the repo
# This workflow will run every 30 mins to hopefully ensure that credentials
# don't expire even if this script errors.
name: refresh-test-credentials
# For now this only runs on a schedule once a day. Once we have made some of the
# plugin workflows more incremental we will run this on _every_ commit to main
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
# Schedule every 30 mins
- cron: '*/30 * * * *'
jobs:
refresh-test-credentials:
name: refresh-test-credentials
environment: ops
runs-on: ubuntu-latest
env:
PR_TOOLS_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PR_TOOLS_GITHUB_APP_PRIVATE_KEY}}
PR_TOOLS_GITHUB_APP_ID: ${{ secrets.PR_TOOLS_GITHUB_APP_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'
- name: Authenticate to google with an ops user
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_OPS_CREDENTIALS_JSON }}'
create_credentials_file: true
- name: Setup external pr tools
uses: ./.github/workflows/setup-external-pr-tools
# These credentials are not supposed to be secrets
- name: Refresh credentials for the oso-test-dummy user on the testing environment
shell: bash
run: |
cd ops/external-prs &&
bash scripts/rotate-service-account.sh [email protected] dummy.json &&
pnpm tools oso refresh-gcp-credentials --secret=false testing dummy.json GOOGLE_TEST_DUMMY_CREDENTIALS_JSON
env:
PR_TOOLS_REPO: ${{ github.repository }}
# These credentials are intended to be secret
- name: Refresh credentials for the bigquery-admin user on the many apps and environments
shell: bash
run: |
cd ops/external-prs &&
bash scripts/rotate-service-account.sh [email protected] bigquery-admin.json &&
pnpm tools oso --repo ${{ github.repository }} refresh-gcp-credentials external-prs-app bigquery-admin.json GOOGLE_BQ_ADMIN_CREDENTIALS_JSON &&
pnpm tools oso --repo ${{ github.repository }} refresh-gcp-credentials deploy bigquery-admin.json GOOGLE_BQ_ADMIN_CREDENTIALS_JSON &&
pnpm tools oso --repo opensource-observer/oss-directory refresh-gcp-credentials external-prs-app bigquery-admin.json GOOGLE_BQ_ADMIN_CREDENTIALS_JSON
rebuild-docker-public-vars:
name: rebuild-docker-public-vars
environment: testing
runs-on: ubuntu-latest
permissions:
packages: write
env:
# Frontend variables
NODE_ENV: ${{ vars.NODE_ENV }}
PLASMIC_PROJECT_ID: ${{ vars.PLASMIC_PROJECT_ID }}
PLASMIC_PROJECT_API_TOKEN: ${{ vars.PLASMIC_PROJECT_API_TOKEN }}
NEXT_PUBLIC_DOMAIN: ${{ vars.NEXT_PUBLIC_DOMAIN }}
NEXT_PUBLIC_DB_GRAPHQL_URL: ${{ vars.NEXT_PUBLIC_DB_GRAPHQL_URL }}
HASURA_URL: ${{ vars.HASURA_URL }}
OSO_API_KEY: ${{ secrets.OSO_API_KEY }}
GOOGLE_PROJECT_ID: "opensource-observer"
GOOGLE_TEST_DUMMY_CREDENTIALS_JSON: ${{ vars.GOOGLE_TEST_DUMMY_CREDENTIALS_JSON }}
PUBLIC_VARS_TEST: "THISISATEST"
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Write public vars
run: |
bash .github/scripts/save-public-vars.sh ${{ github.sha }} \
NODE_ENV \
PLASMIC_PROJECT_ID \
PLASMIC_PROJECT_API_TOKEN \
NEXT_PUBLIC_DOMAIN \
NEXT_PUBLIC_DB_GRAPHQL_URL \
HASURA_URL \
OSO_API_KEY \
GOOGLE_PROJECT_ID \
GOOGLE_TEST_DUMMY_CREDENTIALS_JSON \
PUBLIC_VARS_TEST