Skip to content

Commit

Permalink
Merge pull request #121 from octue/fix-contact-form
Browse files Browse the repository at this point in the history
Fix contact form
  • Loading branch information
thclark authored Jul 7, 2023
2 parents bccaacf + 5c8a32a commit 6c91f3d
Show file tree
Hide file tree
Showing 21 changed files with 216 additions and 269 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/add-issues-to-board.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: add-issues-to-board

on:
issues:
types: [opened, reopened, transferred]

jobs:
add-issues-to-board:
runs-on: ubuntu-latest
steps:
- name: Add to Board
uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/octue/projects/22
github-token: ${{ secrets.PROJECT_ISSUES_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/gcloud-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- id: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- id: deploy-contact
uses: google-github-actions/deploy-cloud-functions@main
Expand All @@ -19,8 +19,8 @@ jobs:
runtime: python38
region: europe-west1
credentials: ${{ secrets.GCP_SERVICE_ACCOUNT }}
env_vars: HUBSPOT_API_KEY=${{ secrets.HUBSPOT_API_KEY }},ACCESS_CONTROL_ALLOW_ORIGIN=${{ secrets.ACCESS_CONTROL_ALLOW_ORIGIN }},SUPPORT_PIPELINE_TICKET_OWNER_ID=${{ secrets.SUPPORT_PIPELINE_TICKET_OWNER_ID }}
source_dir: gcloud/functions/hubspot
env_vars: MAILGUN_API_KEY=${{ secrets.MAILGUN_API_KEY }},MAILCHIMP_API_KEY=${{ secrets.MAILCHIMP_API_KEY }}
source_dir: gcloud/functions

- id: deploy-subscribe
uses: google-github-actions/deploy-cloud-functions@main
Expand All @@ -29,5 +29,5 @@ jobs:
runtime: python38
region: europe-west1
credentials: ${{ secrets.GCP_SERVICE_ACCOUNT }}
env_vars: HUBSPOT_API_KEY=${{ secrets.HUBSPOT_API_KEY }},ACCESS_CONTROL_ALLOW_ORIGIN=${{ secrets.ACCESS_CONTROL_ALLOW_ORIGIN }}
source_dir: gcloud/functions/hubspot
env_vars: MAILGUN_API_KEY=${{ secrets.MAILGUN_API_KEY }},MAILCHIMP_API_KEY=${{ secrets.MAILCHIMP_API_KEY }}
source_dir: gcloud/functions
23 changes: 11 additions & 12 deletions .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
name: semantic

on: [push]
on:
pull_request:
branches:
- main

jobs:
check-semantic-version:
if: "!contains(github.event.head_commit.message, 'skipci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# Set fetch-depth to 0 to fetch all tags (necessary for git-mkver to determine the correct semantic version).
fetch-depth: 0
- uses: actions/setup-python@v2
- name: Install git-mkver
run: |
curl -L https://github.com/idc101/git-mkver/releases/download/v1.2.1/git-mkver-linux-amd64-1.2.1.tar.gz \
| tar xvz \
&& sudo mv git-mkver /usr/local/bin
- name: Install semantic version checker
run: pip install git+https://github.com/octue/conventional-commits

- name: Check version
run: check-semantic-version package.json
uses: octue/check-semantic-version@1.0.0.beta-9
with:
path: package.json
breaking_change_indicated_by: major
21 changes: 0 additions & 21 deletions .github/workflows/synced-add-issues-to-octue-board.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/update-pr.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/update-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow updates the pull request description with an auto-generated section containing the categorised commit
# message headers of the commits since the last pull request merged into main. The auto generated section is enveloped
# between two comments: "<!--- START AUTOGENERATED NOTES --->" and "<!--- END AUTOGENERATED NOTES --->". Anything
# outside these in the description is left untouched. Auto-generated updates can be skipped for a commit if
# "<!--- SKIP AUTOGENERATED NOTES --->" is added to the pull request description.

name: update-pull-request

# Only trigger for pull requests into main branch.
on:
pull_request:
branches:
- main

jobs:
description:
if: "!contains(github.event.pull_request.body, '<!--- SKIP AUTOGENERATED NOTES --->')"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Generate PR description
uses: octue/generate-pull-request-description@1.0.0.beta-2
id: pr-description
with:
pull_request_url: ${{ github.event.pull_request.url }}
api_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update pull request body
uses: riskledger/update-pr-description@v2
with:
body: ${{ steps.pr-description.outputs.pull_request_description }}
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,8 @@ yarn-error.log
# Storybook build files
build-storybook.log
storybook-static


# IDEs
.idea/
.vscode/
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ repos:
hooks:
- id: check-branch-name
args:
# Main branch...
- '^main$'
- '^dev$'
- '^staging$'
- '^devops/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^doc/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^feature/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^fix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^hotfix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^refactor/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
- '^release/(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
# Or a descriptive kebab-case branch name
# which, if it includes an issue number, will
# auto-link pull requests to that issue on github, eg:
# my-branch-to-fix-issue-#6
- '^([a-z][a-z0-9#/]*)(-[a-z0-9#]+)*$'

- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.2.1'
hooks:
- id: prettier

- repo: https://github.com/octue/pre-commit-hooks
rev: 0.4.0
rev: 0.9.0
hooks:
- id: check-commit-message-is-conventional
stages: [commit-msg]
File renamed without changes.
File renamed without changes.
File renamed without changes.
132 changes: 0 additions & 132 deletions gcloud/functions/hubspot/hubspot.py

This file was deleted.

3 changes: 0 additions & 3 deletions gcloud/functions/hubspot/requirements.txt

This file was deleted.

47 changes: 47 additions & 0 deletions gcloud/functions/mailchimp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import requests
from os import environ
import hashlib


# Get list ids:
# resp = requests.get(
# f"{MAILCHIMP_BASE_URL}/lists", auth=("apikey", MAILCHIMP_API_KEY)
# )
# resp.raise_for_status()
# print(resp.json()['lists'][0]['id'])
MAILCHIMP_LIST_IDS = {
"Octue Newsletter": "cf71ac7a6b",
}
MAILCHIMP_LIST_ID = MAILCHIMP_LIST_IDS["Octue Newsletter"]

MAILCHIMP_API_KEY = environ.get("MAILCHIMP_API_KEY", None)
MAILCHIMP_SERVER_DOMAIN = environ.get("MAILCHIMP_SERVER_DOMAIN", "us21")
MAILCHIMP_BASE_URL = f"https://{MAILCHIMP_SERVER_DOMAIN}.api.mailchimp.com/3.0"

if MAILCHIMP_API_KEY is None:
raise ValueError("The MAILCHIMP_API_KEY must be set.")


def add_or_update_subscriber(email):
"""Add a subscriber to the main mailchimp list, o if they're already present, update their status to 'subscribed'"""

endpoint = (
f"{MAILCHIMP_BASE_URL}/lists/{MAILCHIMP_LIST_ID}/members/{_email_hash(email)}"
)
data = {
"email_address": email,
"status_if_new": "subscribed",
"status": "subscribed",
}
headers = {
"Authorization": f"apikey {MAILCHIMP_API_KEY}",
"Content-Type": "application/json",
}

response = requests.put(endpoint, json=data, headers=headers, timeout=5)
response.raise_for_status()


def _email_hash(email):
"""Generate an MD5 hash of an email address, which is required by the Mailchimp API for identifying the member in the list."""
return hashlib.md5(email.encode("utf-8")).hexdigest()
Loading

0 comments on commit 6c91f3d

Please sign in to comment.