Skip to content

release: 2024-10-28 #308

release: 2024-10-28

release: 2024-10-28 #308

Workflow file for this run

name: Postgres CI/CD
on:
push:
branches:
- main
paths:
- "clouds/postgres/**"
- ".github/workflows/postgres.yml"
pull_request:
paths:
- "clouds/postgres/**"
- ".github/workflows/postgres.yml"
workflow_dispatch:
workflow_call:
env:
NODE_VERSION: 14
PYTHON3_VERSION: 3.8.10
VIRTUALENV_VERSION: 20.21.1
GCLOUD_VERSION: 290.0.1
jobs:
test:
runs-on: ubuntu-20.04
timeout-minutes: 30
env:
PG_PREFIX: ci_${{ github.sha }}_${{ github.run_id }}_${{ github.run_attempt }}_
PG_HOST: ${{ secrets.PG_HOST_CI }}
PG_DATABASE: ${{ secrets.PG_DATABASE_CI }}
PG_USER: ${{ secrets.PG_USER_CI }}
PG_PASSWORD: ${{ secrets.PG_PASSWORD_CI }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check diff
uses: technote-space/get-diff-action@v4
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup python 3
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON3_VERSION }}
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Run linter and tests
run: |
cd clouds/postgres
make lint && \
make deploy diff="$GIT_DIFF" && \
make test diff="$GIT_DIFF" && \
make remove
deploy-internal:
if: github.ref_name == 'main'
needs: test
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
include:
- host: PG_HOST_CD
database: PG_DATABASE_CD
user: PG_USER_CD
password: PG_PASSWORD_CD
- host: PG_HOST_CI
database: PG_DATABASE_CI
user: PG_USER_CI
password: PG_PASSWORD_CI
env:
PG_HOST: ${{ secrets[matrix.host] }}
PG_DATABASE: ${{ secrets[matrix.database] }}
PG_USER: ${{ secrets[matrix.user] }}
PG_PASSWORD: ${{ secrets[matrix.password] }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check diff
uses: technote-space/get-diff-action@v4
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup python 3
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON3_VERSION }}
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Run deploy
run: |
cd clouds/postgres
make deploy diff="$GIT_DIFF" production=1
publish:
if: github.ref_name == 'stable'
needs: test
runs-on: ubuntu-20.04
timeout-minutes: 10
env:
PACKAGE_BUCKET: gs://carto-analytics-toolbox-core/postgres
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup python 3
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON3_VERSION }}
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Auth google
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_PRODUCTION_RELEASE_SA }}
project_id: ${{ secrets.GCLOUD_PRODUCTION_PROJECT }}
create_credentials_file: true
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v0
with:
version: ${{ env.GCLOUD_VERSION }}
project_id: ${{ secrets.GCLOUD_PRODUCTION_PROJECT }}
- name: Create package
run: |
cd clouds/postgres
make create-package
- name: Publish package
run: |
cd clouds/postgres
gsutil -h "Content-Type:application/zip" -m cp dist/*.zip ${{ env.PACKAGE_BUCKET }}/
gsutil -h "Content-Type:application/zip" -m cp dist/*.zip ${{ env.PACKAGE_BUCKET }}/carto-analytics-toolbox-core-postgres-latest.zip
gsutil -h "Content-Type:application/json" -m cp dist/*.json ${{ env.PACKAGE_BUCKET }}/