Skip to content

Commit 8a418c4

Browse files
committed
Adding catalog-update.yml
1 parent c8a6c1e commit 8a418c4

File tree

2 files changed

+41
-44
lines changed

2 files changed

+41
-44
lines changed

.github/workflows/db-update-content.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ on:
1818
OP_SERVICE_ACCOUNT_TOKEN:
1919
description: 1Password Service Account token
2020
required: true
21-
OP_FEEDS_SERVICE_ACCOUNT_TOKEN:
22-
description: 1Password token for feeds secret
23-
required: true
2421
POSTGRE_SQL_INSTANCE_NAME:
2522
description: PostgreSQL instance name
2623
required: true
@@ -170,44 +167,3 @@ jobs:
170167
name: populate-gbfs-${{ inputs.ENVIRONMENT }}.log
171168
path: populate-gbfs.log
172169

173-
174-
update-gcp-secret:
175-
name: Update GCP Secrets
176-
if: ${{ contains('repository_dispatch,workflow_dispatch', github.event_name) && !inputs.DRY_RUN }}
177-
runs-on: ubuntu-latest
178-
steps:
179-
- name: Authenticate to Google Cloud
180-
uses: google-github-actions/auth@v2
181-
with:
182-
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}
183-
184-
- name: Google Cloud Setup
185-
uses: google-github-actions/setup-gcloud@v2
186-
187-
- name: Load secrets from 1Password
188-
id: onepw_secrets
189-
uses: 1password/[email protected]
190-
with:
191-
export-env: true # Export loaded secrets as environment variables
192-
env:
193-
# This alternate service account token gives access to a vault writable by some third
194-
# party people who can update the list of feeds requiring authorization and their tokens
195-
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_FEEDS_SERVICE_ACCOUNT_TOKEN }}
196-
JSON_FEEDS_WITH_TOKENS: "op://lijd6lj7lyw7dajea6x3zgf53m/l6sr2cnpjj3cbw3t5amlu7vui4/credential"
197-
198-
- name: Create or Update Auth Secret
199-
env:
200-
PROJECT_ID: ${{ inputs.PROJECT_ID }}
201-
ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
202-
SECRET_VALUE: ${{ env.JSON_FEEDS_WITH_TOKENS }}
203-
SECRET_NAME: FEEDS_CREDENTIALS
204-
run: |
205-
echo "Processing secret $SECRET_NAME in project $PROJECT_ID..."
206-
207-
if gcloud secrets describe $SECRET_NAME --project=$PROJECT_ID; then
208-
echo "Secret $SECRET_NAME already exists in project $PROJECT_ID, updating..."
209-
echo -n "$SECRET_VALUE" | gcloud secrets versions add $SECRET_NAME --data-file=- --project=$PROJECT_ID
210-
else
211-
echo "Secret $SECRET_NAME does not exist in project $PROJECT_ID, creating..."
212-
echo -n "$SECRET_VALUE" | gcloud secrets create $SECRET_NAME --data-file=- --replication-policy="automatic" --project=$PROJECT_ID
213-
fi

.github/workflows/db-update.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,44 @@ jobs:
9090
DRY_RUN: ${{ inputs.DRY_RUN }}
9191
CHECKOUT_REF: main
9292
secrets: inherit
93+
94+
update-gcp-secret:
95+
name: Update GCP Secrets
96+
if: ${{ !inputs.DRY_RUN }}
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Authenticate to Google Cloud
100+
uses: google-github-actions/auth@v2
101+
with:
102+
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}
103+
104+
- name: Google Cloud Setup
105+
uses: google-github-actions/setup-gcloud@v2
106+
107+
- name: Load secrets from 1Password
108+
id: onepw_secrets
109+
uses: 1password/[email protected]
110+
with:
111+
export-env: true # Export loaded secrets as environment variables
112+
env:
113+
# This alternate service account token gives access to a vault writable by some third
114+
# party people who can update the list of feeds requiring authorization and their tokens
115+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_FEEDS_SERVICE_ACCOUNT_TOKEN }}
116+
JSON_FEEDS_WITH_TOKENS: "op://lijd6lj7lyw7dajea6x3zgf53m/l6sr2cnpjj3cbw3t5amlu7vui4/credential"
117+
118+
- name: Create or Update Auth Secret
119+
env:
120+
PROJECT_ID: ${{ inputs.PROJECT_ID }}
121+
ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
122+
SECRET_VALUE: ${{ env.JSON_FEEDS_WITH_TOKENS }}
123+
SECRET_NAME: FEEDS_CREDENTIALS
124+
run: |
125+
echo "Processing secret $SECRET_NAME in project $PROJECT_ID..."
126+
127+
if gcloud secrets describe $SECRET_NAME --project=$PROJECT_ID; then
128+
echo "Secret $SECRET_NAME already exists in project $PROJECT_ID, updating..."
129+
echo -n "$SECRET_VALUE" | gcloud secrets versions add $SECRET_NAME --data-file=- --project=$PROJECT_ID
130+
else
131+
echo "Secret $SECRET_NAME does not exist in project $PROJECT_ID, creating..."
132+
echo -n "$SECRET_VALUE" | gcloud secrets create $SECRET_NAME --data-file=- --replication-policy="automatic" --project=$PROJECT_ID
133+
fi

0 commit comments

Comments
 (0)