Skip to content

Commit

Permalink
Merge pull request #6 from gohypergiant/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
imtmcdonald authored Sep 14, 2023
2 parents 98bfac3 + 8ac43d1 commit 14e68c9
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fly.toml
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug Report
about: Create an issue regarding a bug
title: ''
labels: ''
assignees: ''

---

## Expected Behavior

<!--- Tell us what should happen -->

## Current Behavior

<!--- Tell us what happens instead of the expected behavior -->

## Possible Solution

<!--- Not obligatory, but suggest a fix/reason for the bug, -->

## Steps to Reproduce

<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context (Environment)

<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

<!--- Provide a general summary of the issue in the Title above -->

## Detailed Description

<!--- Provide a detailed description of the change or addition you are proposing -->

## Possible Implementation

<!--- Not obligatory, but suggest an idea for implementing addition or change -->
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature Request
about: Create an issue regarding a feature request
title: ''
labels: ''
assignees: ''

---

## Idea

<!-- Please describe the desired behavior, pitch your idea, or suggest improvements -->

## Is your feature related to a bug?

<!-- Refer to a an existing bug, you can use #bugid -->

## Alternatives

<!-- Have you considered alternative solutions or implementations? Do you have an idea on how this should be implemented? -->

## Additional Info

<!-- Provide additional information or links to resources that can help with the creation of this feature. -->
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Other
about: If nothing else matches
title: ''
labels: ''
assignees: ''

---

<!-- ONLY FOR USE IF NO OTHER SPECIFIC TEMPLATE MATCHES YOUR NEEDS -->

# Summary

<!-- Brief explanation of the issue. -->
66 changes: 66 additions & 0 deletions .github/ISSUE_TEMPLATE/request_for_comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: Request for Comment
about: Create an issue regarding a rfc
title: ''
labels: ''
assignees: ''

---

# Summary

<!-- Brief explanation of the feature. -->

# Basic example

<!-- If the proposal involves a new or changed API, include a basic code example.-->
<!-- Omit this section if it's not applicable.-->

# Motivation

<!-- Why are we doing this? What use cases does it support? What is the expected outcome? -->

<!--
Please focus on explaining the motivation so that if this RFC is not accepted,
the motivation could be used to develop alternative solutions. In other words,
enumerate the constraints you are trying to solve without coupling them too
closely to the solution you have in mind.
-->

# Detailed design

<!--
This is the bulk of the RFC. Explain the design in enough detail for somebody
familiar with React to understand, and for somebody familiar with the
implementation to implement. This should get into specifics and corner-cases,
and include examples of how the feature is used. Any new terminology should be
defined here.
-->

# Drawbacks

<!--
Why should we *not* do this? Please consider:
- implementation cost, both in term of code size and complexity
- integration of this feature with other existing and planned features
- cost of migrating existing integrations (is it a breaking change?)
There are tradeoffs to choosing any path. Attempt to identify them here.
-->

# Alternatives

<!-- What other designs have been considered? What is the impact of not doing this? -->

# Adoption strategy

<!--
If we implement this proposal, how will the team adopt it? Is
this a breaking change? Can we write a codemod? Should we coordinate with
other projects or libraries?
-->

# Unresolved questions

<!-- Optional, but suggested for first drafts. What parts of the design are still TBD? -->
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Description

<!--- Describe your changes in detail -->

## Related Issue

<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->

## Screenshots (if appropriate):
38 changes: 38 additions & 0 deletions .github/workflows/_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy

on:
push:
branches:
- develop
- stable
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: false

jobs:
set-fly-app-name:
uses: ./.github/workflows/set-fly-app-name.yaml
with:
ref: ${{ inputs.branch || github.head_ref || github.ref }} # Use the input if it's there, otherwise use the head ref, otherwise use the ref

dev:
concurrency: hg-sandbox
if: github.ref == 'refs/heads/develop'
uses: ./.github/workflows/deploy-to-fly.yaml
secrets:
fly_access_token: ${{ secrets.FLY_API_TOKEN }}
with:
app_name: glossary-bot-develop
environment: 'hg-sandbox'

stable:
concurrency: Hypergiant
if: github.ref == 'refs/heads/stable'
uses: ./.github/workflows/deploy-to-fly.yaml
secrets:
fly_access_token: ${{ secrets.FLY_API_TOKEN }}
with:
app_name: glossary-bot-stable
environment: 'Hypergiant'
69 changes: 69 additions & 0 deletions .github/workflows/deploy-to-fly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy Glossary-Bot to Fly

on:
workflow_call:
inputs:
app_name:
description: 'App name'
type: string
required: true
environment:
description: 'Target environment. Defaults to hg-sandbox.'
type: string
required: false
default: 'hg-sandbox'
secrets:
fly_access_token:
description: 'Fly access token'
required: true

concurrency:
group: ${{ inputs.app_name }} # Only one deploy at a time per app
cancel-in-progress: true # Cancel any previous deploys and deploy the latest

jobs:
deploy-glossary-bot:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'hg-sandbox'}}
env:
FLY_API_TOKEN: ${{ secrets.fly_access_token }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Setup flyctl
id: setup-flyctl
uses: superfly/flyctl-actions/setup-flyctl@master

# flyctl launch with these arguments has the same effect as running flyctl deploy --remote-only --config fly.toml --name ${{ steps.set_app_name.outputs.app_name }}
# therefore, we just run flyctl launch instead of flyctl deploy as a sort of upsert operation.
- name: deploy glossary-box
id: flyctl-launch
run: |
ENV_PARAMS=$(printf "%s" "$ENV_CONTENT" | sed 's/$/\\n/' | tr -d '\n')
flyctl launch \
--auto-confirm \
--copy-config \
--ha=false \
--name ${{ inputs.app_name }} \
--now \
--org=${{ vars.FLY_ORG }} \
--region=${{ vars.FLY_REGION }} \
--remote-only \
--reuse-app \
$(printf "%s" "$ENV_PARAMS" | sed 's/^/-e /') \
-e FLY_APP_NAME=${{ inputs.app_name }} \
-e SLACK_TOKEN=${{ secrets.GLOSS_BOT_SLACK_TOKEN }} \
-e SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL }} \
update-pr:
runs-on: ubuntu-latest
needs: [ deploy-glossary-bot ]
steps:
- name: Notify PR of successful update
uses: mshick/add-pr-comment@v2
with:
message: |
:rocket: Deployed to Fly!
:link: https://${{ inputs.app_name }}.fly.dev
29 changes: 29 additions & 0 deletions .github/workflows/set-fly-app-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Set Fly.io App Name

on:
workflow_call:
inputs:
ref:
type: string
description: "The ref to format"
required: true
prefix:
type: string
description: "The prefix to add to the name"
required: false
default: "glossary-bot-"
outputs:
name:
description: "The rendered name of the app"
value: ${{ jobs.set_name.outputs.name }}

jobs:
set_name:
runs-on: ubuntu-latest
outputs:
name: ${{ steps.set_name.outputs.name }}

steps:
- id: set_name
run: |
echo "name=$(echo "${{ inputs.prefix }}${{ inputs.ref }}" | tr '/\' '-' | tr -C '[:lower:][:digit:]' '-' | tr '/\' '-' | sed 's/-*$//g')" >> $GITHUB_OUTPUT
21 changes: 21 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# fly.toml app configuration file generated for glossary-bot on 2023-09-08T04:01:01Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "glossary-bot"
primary_region = "iad"

[build]
builder = "paketobuildpacks/builder:full"

[env]
PORT = "8080"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Flask==1.0.2
Flask==2.2.5
Flask-Migrate==2.2.1
Flask-SQLAlchemy==2.3.2
Flask-Script==2.0.6
Flask-SQLAlchemy==3.0.3
Flask-Script==2.0.5
gunicorn==19.7.1
psycopg2==2.7.5
psycopg2==2.8.1
requests>=2.20.0
responses==0.5.1
responses==0.5.1
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.6.6
python-3.8.18
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.projectKey=glossarybot
sonar.exclusions=tests/**

0 comments on commit 14e68c9

Please sign in to comment.