Set up gcloud after auth to remove warning #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pipeline | |
on: push | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:14.5 | |
env: | |
POSTGRES_USER: postgresql | |
POSTGRES_PASSWORD: postgresql | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: install python dependencies | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
pushd web-components | |
npm install | |
npx playwright install-deps chromium | |
npx playwright install chromium | |
popd | |
- name: install postgres client | |
run: | | |
sudo apt-get update | |
sudo apt-get install --yes postgresql-client | |
- name: create test database | |
run: | | |
psql --host localhost --username postgresql < databases/drop_and_create_databases.sql | |
make migrate migrate-test | |
env: | |
PGPASSWORD: postgresql | |
DATABASE_URL: 'postgresql://localhost:5432/negotiator_test?user=negotiator&password=negotiator' | |
- name: run tests | |
env: | |
PORT: 8081 | |
USE_FLASK_DEBUG_MODE: true | |
NEGOTIATOR_LOG_LEVEL: DEBUG | |
SECRET_KEY: 2vaR+Kp/SbVUQwZ73Uu7ul3OCCI= | |
DATABASE_URL: 'postgresql://localhost:5432/negotiator_test?user=negotiator&password=negotiator' | |
run: | | |
npm run build --prefix web-components | |
npm run test --prefix web-components | |
source venv/bin/activate | |
mypy negotiator tests | |
python -m unittest | |
google-cloud-build: | |
runs-on: ubuntu-latest | |
needs: [test] | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: "install python dependencies" | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
npm install --prefix web-components | |
- uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: "${{ secrets.GOOGLE_FEDERATION_WORKLOAD_IDENTITY_PROVIDER }}" | |
service_account: "${{ secrets.GOOGLE_FEDERATION_SERVICE_ACCOUNT }}" | |
- uses: google-github-actions/setup-gcloud@v1 | |
- name: "build" | |
run: |- | |
sudo add-apt-repository ppa:cncf-buildpacks/pack-cli | |
sudo apt-get update | |
sudo apt-get install -y pack-cli | |
npm run build --prefix web-components | |
pack build us-central1-docker.pkg.dev/${{ secrets.GOOGLE_PROJECT_ID }}/negotiator-review/negotiator:${{ github.sha }} --builder=gcr.io/buildpacks/builder:v1 | |
gcloud auth configure-docker us-central1-docker.pkg.dev | |
docker push us-central1-docker.pkg.dev/${{ secrets.GOOGLE_PROJECT_ID }}/negotiator-review/negotiator:${{ github.sha }} | |
google-cloud-sql: | |
runs-on: ubuntu-latest | |
needs: [google-cloud-build] | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: install python dependencies | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
- name: install postgres client | |
run: | | |
sudo apt-get update | |
sudo apt-get install --yes postgresql-client | |
- uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: "${{ secrets.GOOGLE_FEDERATION_WORKLOAD_IDENTITY_PROVIDER }}" | |
service_account: "${{ secrets.GOOGLE_FEDERATION_SERVICE_ACCOUNT }}" | |
- uses: google-github-actions/setup-gcloud@v1 | |
- name: cloud-sql-proxy | |
run: | | |
curl https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.0.0-preview.0/cloud-sql-proxy.linux.amd64 --output cloud-sql-proxy | |
chmod +x cloud-sql-proxy | |
sudo mv cloud-sql-proxy /usr/bin/cloud-sql-proxy | |
- name: migrate | |
env: | |
DATABASE_URL: ${{ secrets.REVIEW_MIGRATE_URL }} | |
run: | | |
cloud-sql-proxy --port 6000 ${{ secrets.GOOGLE_PROJECT_ID }}:us-central1:negotiator-review & | |
sleep 6 | |
make migrate | |
google-cloud-run: | |
runs-on: ubuntu-latest | |
needs: [google-cloud-sql] | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: "${{ secrets.GOOGLE_FEDERATION_WORKLOAD_IDENTITY_PROVIDER }}" | |
service_account: "${{ secrets.GOOGLE_FEDERATION_SERVICE_ACCOUNT }}" | |
- uses: google-github-actions/setup-gcloud@v1 | |
- name: deploy | |
run: |- | |
gcloud run deploy negotiator-review \ | |
--image us-central1-docker.pkg.dev/${{ secrets.GOOGLE_PROJECT_ID }}/negotiator-review/negotiator:${{ github.sha }} \ | |
--region us-central1 \ | |
--platform managed |