-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1st github actions config * Updating gcp authentication creds * Auth gc from github actions * Switchin push to true * Adding missing entrypoint * Updating entrypoint file * Skipping entrypoint by the moment * Removing schema search path * Adding review-env setup (database creation) * Replacing vars * Adding adapter to database.yml * Testing * Returning back entrypoint config * Reverting entrypoint execution * Turning into underscore db name * Docker layer cache issue * Adding password strongly * Adding username * Turning entrypoint back on * Test * Skipping entrypoint * Test * Test * test * Testing * Trying with tankef config * Test * Debuggin * Adding google-cloud-secret_manager gem * Test * Enabling entrypoint * Test * Adding permissions to entrypoint file * Updating gitignore * Test
- Loading branch information
1 parent
98cdae9
commit 5fc499d
Showing
11 changed files
with
330 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
deploy-name: | ||
required: true | ||
type: string | ||
cloud-sql-instance: | ||
required: true | ||
type: string | ||
cloud-sql-username-secret: | ||
required: false | ||
type: string | ||
default: projects/582875546495/secrets/database-username:latest | ||
cloud-sql-password-secret: | ||
required: false | ||
type: string | ||
default: projects/582875546495/secrets/database-password:latest | ||
cloud-run-container-image: | ||
required: true | ||
type: string | ||
cloud-run-service-suffix: | ||
required: false | ||
type: string | ||
cloud-run-minimum-instances: | ||
required: false | ||
type: number | ||
default: 0 | ||
|
||
jobs: | ||
service-deploy: | ||
name: Service Deploy | ||
runs-on: ubuntu-latest | ||
env: | ||
DATABASE_NAME: sepomex_${{ inputs.deploy-name }} | ||
steps: | ||
# actions/checkout MUST come before auth | ||
- name: Checkout the code | ||
uses: actions/checkout@v3.1.0 | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v0.8.0 | ||
with: | ||
service_account: github-actions@sepomex-365521.iam.gserviceaccount.com | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v0.6.0 | ||
|
||
- name: URLEncode Cloud SQL Instance string | ||
id: url-encode-cloud-sql-instance | ||
run: |- | ||
ruby -e 'require "erb"; puts "encoded-value=#{ERB::Util.url_encode("${{ inputs.cloud-sql-instance }}")}"' >> $GITHUB_OUTPUT | ||
- name: Register Deploy Start on Github | ||
uses: bobheadxi/deployments@v1.3.0 | ||
id: deploy-start | ||
with: | ||
step: start | ||
ref: ${{ github.head_ref }} | ||
env: ${{ inputs.environment }} | ||
token: ${{ github.token }} | ||
|
||
- name: Set deploy timestamp | ||
id: set-deploy-timestamp | ||
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT | ||
|
||
- name: Deploy to Cloud Run | ||
id: deploy | ||
uses: google-github-actions/deploy-cloudrun@v0.9.0 | ||
with: | ||
region: us-central1 | ||
service: sepomex-${{ inputs.deploy-name }} | ||
suffix: ${{ inputs.cloud-run-service-suffix }}-${{ steps.set-deploy-timestamp.outputs.timestamp }} | ||
image: ${{ inputs.cloud-run-container-image }} | ||
secrets: | | ||
DATABASE_USERNAME=${{ inputs.cloud-sql-username-secret }} | ||
DATABASE_PASSWORD=${{ inputs.cloud-sql-password-secret }} | ||
env_vars: | | ||
DATABASE_URL=postgres://%2Fcloudsql%2F${{ steps.url-encode-cloud-sql-instance.outputs.encoded-value }}/${{ env.DATABASE_NAME }} | ||
GOOGLE_CLOUD_PROJECT=sepomex-365521 | ||
flags: |- | ||
--allow-unauthenticated | ||
--add-cloudsql-instances ${{ inputs.cloud-sql-instance }} | ||
--min-instances=${{ inputs.cloud-run-minimum-instances }} | ||
--service-account github-actions@sepomex-365521.iam.gserviceaccount.com | ||
- name: Finalize the deployment state on Github | ||
uses: bobheadxi/deployments@v1.3.0 | ||
if: always() | ||
with: | ||
step: finish | ||
override: true | ||
auto_inactive: true | ||
status: ${{ job.status }} | ||
token: ${{ github.token }} | ||
env_url: ${{ steps.deploy.outputs.url }} | ||
env: ${{ steps.deploy-start.outputs.env }} | ||
deployment_id: ${{ steps.deploy-start.outputs.deployment_id }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Review Environment Setup | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- reopened | ||
|
||
jobs: | ||
create_deployment: | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
name: Create deployment | ||
runs-on: ubuntu-latest | ||
env: | ||
DB_NAME: "sepomex-pr${{ github.event.pull_request.number }}" | ||
GOOGLE_CLOUD_PROJECT: sepomex-365521 | ||
|
||
# Generate a GitHub token that can be exchanged with Google Cloud - see | ||
# https://github.com/google-github-actions/auth/tree/v0.6.0#setting-up-workload-identity-federation | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
# actions/checkout MUST come before auth | ||
- name: Checkout the code | ||
uses: actions/checkout@v3.1.0 | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v0.6.0 | ||
with: | ||
service_account: github-actions@sepomex-365521.iam.gserviceaccount.com | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v0.6.0 | ||
|
||
- name: Ensure a review database exists | ||
run: |- | ||
gcloud sql databases describe ${{ env.DB_NAME }} \ | ||
--instance=sepomex \ | ||
--format="value(name)" \ | ||
&& echo "Database ${{ env.DB_NAME }} already exists" \ | ||
|| gcloud sql databases create ${{ env.DB_NAME }} \ | ||
--instance=sepomex |
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
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
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
Oops, something went wrong.