forked from docusealco/docuseal
-
Notifications
You must be signed in to change notification settings - Fork 2
Add Google OAuth login and GAR CI/CD pipeline #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,71 @@ | ||
| name: Build and Push to Google Artifact Registry | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*.*.*" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Create .version file | ||
| env: | ||
| REF_TYPE: ${{ github.ref_type }} | ||
| REF_NAME: ${{ github.ref_name }} | ||
| COMMIT_SHA: ${{ github.sha }} | ||
| run: | | ||
| if [[ "${REF_TYPE}" == "tag" ]]; then | ||
| echo "${REF_NAME}" > .version | ||
| else | ||
| echo "${COMMIT_SHA}" > .version | ||
| fi | ||
|
|
||
| - name: Authenticate to Google Cloud | ||
| id: auth | ||
| uses: google-github-actions/auth@v2 | ||
| with: | ||
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | ||
| token_format: access_token | ||
|
|
||
| - name: Login to Artifact Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: us-central1-docker.pkg.dev | ||
| username: oauth2accesstoken | ||
| password: ${{ steps.auth.outputs.access_token }} | ||
|
|
||
| - name: Docker meta | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: us-central1-docker.pkg.dev/kencove-prod/docuseal/docuseal | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=sha,prefix=,format=short | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| platforms: linux/amd64 | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
This file contains hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
| skip_before_action :verify_authenticity_token, only: :google_oauth2 | ||
|
|
||
| def google_oauth2 | ||
| user = Users.from_omniauth(request.env['omniauth.auth']) | ||
|
|
||
| if user&.active_for_authentication? | ||
| sign_in_and_redirect(user, event: :authentication) | ||
| else | ||
| redirect_to new_user_session_path, alert: I18n.t('user_not_found') | ||
| end | ||
| end | ||
|
|
||
| def failure | ||
| redirect_to new_user_session_path, alert: I18n.t('authentication_failed') | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -173,6 +173,8 @@ en: &en | |
| sign_in: Sign In | ||
| signing_in: Signing In | ||
| sign_in_with_microsoft: Sign in with Microsoft | ||
| user_not_found: User not found. Please contact your administrator. | ||
| authentication_failed: Authentication failed. Please try again. | ||
|
Comment on lines
+176
to
+177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add translations for non‑English locales. These new keys are only present in 🤖 Prompt for AI Agents |
||
| sign_in_with_google: Sign in with Google | ||
| forgot_your_password_: Forgot your password? | ||
| create_free_account: Create free account | ||
|
|
||
This file contains hidden or 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 hidden or 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,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Users | ||
| module_function | ||
|
|
||
| def from_omniauth(oauth) | ||
| User.find_by(email: oauth.info.email.to_s.downcase) | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
docker metadata-action is_default_branch template variable tag push behavior💡 Result:
In
docker/metadata-action,{{is_default_branch}}is only about the branch ref that triggered the workflow run (i.e., arefs/heads/...run). It returnstrueonly when the workflow was triggered by the repo’s default branch; otherwisefalse. (github.com)That means on a tag push run (
refs/tags/...), there is no triggering branch ref (e.g.,{{branch}}is empty on tag runs), so{{is_default_branch}}is not a reliable way to detect “tag created from default branch”. (github.com)If your goal is “push
latestonly for default branch builds”:type=raw,value=latest,enable={{is_default_branch}}. (github.com)If your goal is “push
lateston release tags”:flavor: latest=autoby default), which generateslatestfor tag/semver/match-style tag strategies. (github.com)Finally, while
{{base_ref}}may sometimes show something on tag push payloads, the action explicitly warns it doesn’t always return the expected branch on tag pushes and is not recommended to rely on for this purpose. (github.com)Citations:
The
latesttag may never be applied on tag-triggered workflows.When this workflow is triggered by a tag push,
github.refisrefs/tags/v*.*.*, not a branch ref. Theis_default_branchtemplate indocker/metadata-actionevaluates whether the current ref is the default branch—which is false for tag pushes. This means thelatesttag will never be applied.If you want
latestto be applied when tagging, consider one of these approaches:flavor: latest=auto(applieslatestfor tag/semver tag strategies)lateston semver tags:type=raw,value=latestlatesttag line if it's not needed🤖 Prompt for AI Agents