-
Notifications
You must be signed in to change notification settings - Fork 25
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/[email protected] | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/[email protected] | ||
with: | ||
service_account: [email protected] | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
|
||
- 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/[email protected] | ||
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/[email protected] | ||
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 [email protected] | ||
- name: Finalize the deployment state on Github | ||
uses: bobheadxi/[email protected] | ||
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/[email protected] | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/[email protected] | ||
with: | ||
service_account: [email protected] | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
|
||
- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,9 @@ jobs: | |
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/[email protected] | ||
uses: docker/[email protected] | ||
with: | ||
version: v0.9.1 | ||
|
||
- name: Build Test Image | ||
id: build-test-image | ||
|
@@ -81,20 +83,32 @@ jobs: | |
path: | | ||
tmp/capybara/screenshots | ||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/[email protected] | ||
with: | ||
service_account: [email protected] | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
|
||
- name: Authorize push to Google Cloud Artifact Registry | ||
run: gcloud auth configure-docker us-central1-docker.pkg.dev | ||
|
||
- name: Build & Push Release Image | ||
id: build-and-push-release-image | ||
uses: docker/[email protected] | ||
with: | ||
push: false | ||
push: true | ||
target: release | ||
platforms: linux/amd64 | ||
builder: ${{ steps.buildx.outputs.name }} | ||
build-args: | | ||
DEVELOPER_UID=${{ steps.variables.outputs.runner-uid }} | ||
DEVELOPER_USERNAME=${{ steps.variables.outputs.runner-user }} | ||
tags: | | ||
us-central1-docker.pkg.dev/icalia-labs-sepomex/sepomex/sepomex-web:${{ steps.variables.outputs.git-commit-short-sha }} | ||
us-central1-docker.pkg.dev/icalia-labs-sepomex/sepomex/sepomex-web:${{ steps.variables.outputs.git-dasherized-branch }} | ||
us-central1-docker.pkg.dev/icalia-labs-sepomex/sepomex/sepomex-web:latest | ||
us-central1-docker.pkg.dev/sepomex-365521/icalialabs-sepomex/sepomex:${{ steps.variables.outputs.git-commit-short-sha }} | ||
us-central1-docker.pkg.dev/sepomex-365521/icalialabs-sepomex/sepomex:${{ steps.variables.outputs.git-dasherized-branch }} | ||
us-central1-docker.pkg.dev/sepomex-365521/icalialabs-sepomex/sepomex:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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.