Skip to content

Commit

Permalink
Merge pull request #18 from davidh16/debug
Browse files Browse the repository at this point in the history
test migration
  • Loading branch information
davidh16 authored Aug 28, 2024
2 parents 99dbdb4 + 7c224b0 commit 5a85a5f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
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

0 comments on commit 5a85a5f

Please sign in to comment.