Skip to content
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

test migration #18

Merged
merged 25 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b631090
chore: add log
Aug 28, 2024
9acd46d
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
100ec82
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
d4cad78
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
88f3b5b
chore: add test migration
Aug 28, 2024
20d3380
Merge remote-tracking branch 'origin/debug' into debug
Aug 28, 2024
07f85d5
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
d00d832
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
c298760
chore: add test migration
Aug 28, 2024
e10e6f5
Merge remote-tracking branch 'origin/debug' into debug
Aug 28, 2024
552885d
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
b296c99
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
1ba3f8f
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
47e7410
chore: add test migration
Aug 28, 2024
9d366d6
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
e789066
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
247d708
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
6cf8293
chore: add test migration
Aug 28, 2024
bfe557a
Merge remote-tracking branch 'origin/debug' into debug
Aug 28, 2024
e36fc1a
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
4b3808d
chore: remove test migration
Aug 28, 2024
d29d937
Update google-cloudrun-docker.yml
davidh16 Aug 28, 2024
b80dea8
chore: add test migration
Aug 28, 2024
a82854a
Merge remote-tracking branch 'origin/debug' into debug
Aug 28, 2024
7c224b0
Merge branch 'master' into debug
davidh16 Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions .github/workflows/google-cloudrun-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ jobs:
-t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }}"

- name: Get changed files in the docs folder
id: changed-files-specific
uses: tj-actions/changed-files@v34
with:
files: migrations/**

- name: Execute Cloud Run Migration Job
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
gcloud run jobs execute migrate \
--project ${{ env.PROJECT_ID }} \

# END - Docker auth and build

- name: Prepare Environment Variables for Deployment
Expand All @@ -118,7 +106,6 @@ jobs:

env_vars=$(jq -r 'to_entries | map("\(.key)=\(.value)") | join(",")' env_vars.json)

echo "env_vars=$env_vars"
# Set the output variable for the step
echo "::set-output name=env_vars::$env_vars"

Expand All @@ -141,3 +128,22 @@ jobs:
# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}

- name: Get changed files in the docs folder
uses: dorny/paths-filter@v3
id: filter
with:
fetch-depth: 0
filters: |
migrations:
- 'migrations/**'

- name: Debug - List Changed Files
run: echo "${{ steps.filter.outputs.migrations }}"

- name: Execute Cloud Run Migration Job
if: steps.filter.outputs.migrations == 'true'
run: |
gcloud run jobs execute migrate \
--project ${{ env.PROJECT_ID }} \
--region ${{ env.REGION }} \
1 change: 1 addition & 0 deletions migrations/20240828211601_testaxxx.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS testaxxx;
7 changes: 7 additions & 0 deletions migrations/20240828211601_testaxxx.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS testaxxx (
uuid uuid NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
/*----------------------------*/
-- extras

);
9 changes: 6 additions & 3 deletions service/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ func (s Service) SendNewPasswordEmail(emailAddress string, newPassword string) e
return nil
}

func (s Service) sendEmail(to string, subject string, body string) error {
func (s Service) sendEmail(receiver string, subject string, body string) error {

receivers := []string{
to,
receiver,
}

mime := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"
subject = "Subject: " + subject + "\n"
from := fmt.Sprintf("From: %s\n", "Password Lock")
msg := []byte(from + subject + mime + "\n" + body)
to := fmt.Sprintf("To: %s\n", receiver)
msg := []byte(to + from + subject + mime + "\n" + body)

auth := smtp.PlainAuth("", s.Cfg.SmtpUsername, s.Cfg.SmtpPassword, s.Cfg.SmtpHost)

fmt.Println(auth)

// Sending email.
err := smtp.SendMail(s.Cfg.SmtpHost+":"+s.Cfg.SmtpPort, auth, s.Cfg.SmtpFrom, receivers, msg)
if err != nil {
Expand Down
Loading