diff --git a/.github/workflows/google-cloudrun-docker.yml b/.github/workflows/google-cloudrun-docker.yml index ac36aa3..459f502 100644 --- a/.github/workflows/google-cloudrun-docker.yml +++ b/.github/workflows/google-cloudrun-docker.yml @@ -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 @@ -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" @@ -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 }} \ diff --git a/migrations/20240828211601_testaxxx.down.sql b/migrations/20240828211601_testaxxx.down.sql new file mode 100644 index 0000000..8e36ad2 --- /dev/null +++ b/migrations/20240828211601_testaxxx.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS testaxxx; diff --git a/migrations/20240828211601_testaxxx.up.sql b/migrations/20240828211601_testaxxx.up.sql new file mode 100644 index 0000000..cab8bcf --- /dev/null +++ b/migrations/20240828211601_testaxxx.up.sql @@ -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 + +); diff --git a/service/smtp.go b/service/smtp.go index 4aee2c0..cb2f209 100644 --- a/service/smtp.go +++ b/service/smtp.go @@ -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 {