Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
c013cc1d
Commit
c013cc1d
authored
4 years ago
by
Will McCutchen
Browse files
Options
Downloads
Patches
Plain Diff
Deploy to fly.io
parent
52382e08
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.github/workflows/cleanup.yaml
+0
-32
0 additions, 32 deletions
.github/workflows/cleanup.yaml
.github/workflows/continuous_delivery.yaml
+16
-95
16 additions, 95 deletions
.github/workflows/continuous_delivery.yaml
Makefile
+13
-5
13 additions, 5 deletions
Makefile
fly.toml
+21
-0
21 additions, 0 deletions
fly.toml
with
50 additions
and
132 deletions
.github/workflows/cleanup.yaml
deleted
100644 → 0
+
0
−
32
View file @
52382e08
name
:
Cleanup
on
:
pull_request
:
branches
:
[
master
]
types
:
[
closed
]
jobs
:
cleanup_staging_deploy
:
name
:
Cleanup Staging Deploy
runs-on
:
ubuntu-latest
steps
:
-
name
:
Checkout
uses
:
actions/checkout@v2
-
name
:
Setup gcloud CLI
uses
:
GoogleCloudPlatform/github-actions/setup-gcloud@master
with
:
version
:
'
285.0.0'
project_id
:
${{ secrets.GCP_PROJECT_ID }}
service_account_email
:
${{ secrets.GCP_SA_EMAIL }}
service_account_key
:
${{ secrets.GCP_SA_KEY }}
export_default_credentials
:
true
-
name
:
Setup deployment parameters
id
:
deployment_params
run
:
|
pr_number=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH")
echo "::set-output name=version::pr${pr_number}"
-
name
:
Remove deployment
run
:
gcloud app versions delete --project="${{ secrets.GCP_PROJECT_ID }}" "${{ steps.deployment_params.outputs.version }}"
This diff is collapsed.
Click to expand it.
.github/workflows/continuous_delivery.yaml
+
16
−
95
View file @
c013cc1d
# This workflow implements continuous delivery with automated testing and fully
# autonomous deploys to staging and production.
#
# If executed on a pull request, this will trigger a "staging" deploy to a
# non-primary app engine version named "pr<number>" for the current pull
# request number IFF tests pass.
#
# If executed on a push to master, this will trigger a "production" deploy IFF
# tests pass.
#
# A separate "Cleanup" workflow (cleanup.yaml) runs when pull requests are
# closed to remove the staging deploy for that pull request.
# autonomous deploys to production on merge.
name
:
CD
# Translated: "Execute this workflow on pushes to master OR on pull requests
...
...
@@ -24,19 +14,6 @@ on:
branches
:
[
master
]
jobs
:
lint
:
name
:
Lint
runs-on
:
ubuntu-latest
steps
:
-
name
:
Setup
uses
:
actions/setup-go@v2
-
name
:
Checkout
uses
:
actions/checkout@v2
-
name
:
Lint
run
:
make lint
test
:
name
:
Test
runs-on
:
ubuntu-latest
...
...
@@ -50,8 +27,11 @@ jobs:
-
name
:
Build
run
:
make build
-
name
:
Lint
run
:
make lint
-
name
:
Test
run
:
make testci
run
:
git show &&
make testci
-
name
:
Code coverage
uses
:
codecov/codecov-action@v1
...
...
@@ -81,95 +61,36 @@ jobs:
-
name
:
Test
run
:
make test
staging_deploy
:
name
:
Staging Deploy
if
:
github.ref != 'refs/heads/master'
runs-on
:
ubuntu-latest
needs
:
[
lint
,
test
]
steps
:
-
name
:
Checkout
uses
:
actions/checkout@v2
-
name
:
Setup gcloud CLI
uses
:
GoogleCloudPlatform/github-actions/setup-gcloud@master
with
:
version
:
'
285.0.0'
project_id
:
${{ secrets.GCP_PROJECT_ID }}
service_account_email
:
${{ secrets.GCP_SA_EMAIL }}
service_account_key
:
${{ secrets.GCP_SA_KEY }}
export_default_credentials
:
true
-
name
:
Setup deployment parameters
id
:
deployment_params
run
:
|
pr_number=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH")
echo "::set-output name=version::pr${pr_number}"
-
name
:
Notify start
id
:
deployment
uses
:
bobheadxi/deployments@v0.4.0
with
:
env
:
staging
ref
:
${{ github.head_ref }}
step
:
start
token
:
${{ secrets.GITHUB_TOKEN }}
-
name
:
Deploy
run
:
gcloud app deploy --quiet --no-promote --project="${{ secrets.GCP_PROJECT_ID }}" --version="${{ steps.deployment_params.outputs.version }}"
-
name
:
Notify finish
uses
:
bobheadxi/deployments@v0.4.0
with
:
step
:
finish
deployment_id
:
${{ steps.deployment.outputs.deployment_id }}
token
:
${{ secrets.GITHUB_TOKEN }}
env
:
staging
status
:
${{ job.status }}
env_url
:
'
https://${{
steps.deployment_params.outputs.version
}}-dot-httpbingo.uc.r.appspot.com'
logs
:
'
https://console.cloud.google.com/logs/viewer?project=${{
secrets.GCP_PROJECT_ID
}}&resource=gae_app%2Fmodule_id%2Fdefault%2Fversion_id%2F${{
steps.deployment_params.outputs.version
}}'
production_deploy
:
name
:
Production Deploy
if
:
github.ref == 'refs/heads/master'
runs-on
:
ubuntu-latest
needs
:
[
lint
,
test
]
needs
:
[
test
]
steps
:
-
name
:
Checkout
uses
:
actions/checkout@v2
-
name
:
Setup gcloud CLI
uses
:
GoogleCloudPlatform/github-actions/setup-gcloud@master
with
:
version
:
'
285.0.0'
project_id
:
${{ secrets.GCP_PROJECT_ID }}
service_account_email
:
${{ secrets.GCP_SA_EMAIL }}
service_account_key
:
${{ secrets.GCP_SA_KEY }}
export_default_credentials
:
true
-
name
:
Setup deployment parameters
id
:
deployment_params
run
:
|
version=$(echo "${GITHUB_SHA}" | head -c 8)
echo "::set-output name=version::${version}"
-
name
:
Notify start
id
:
deployment
uses
:
bobheadxi/deployments@v0.4.
0
uses
:
bobheadxi/deployments@v0.4.
2
with
:
step
:
start
token
:
${{ secrets.GITHUB_TOKEN }}
env
:
staging
env
:
production
-
name
:
Deploy
run
:
gcloud app deploy --quiet --project="${{ secrets.GCP_PROJECT_ID }}" --version="${{ steps.deployment_params.outputs.version }}"
uses
:
superfly/flyctl-actions@1.1
with
:
args
:
"
deploy
--strategy
rolling"
env
:
FLY_API_TOKEN
:
${{ secrets.FLY_API_TOKEN }}
-
name
:
Notify finish
uses
:
bobheadxi/deployments@v0.4.
0
uses
:
bobheadxi/deployments@v0.4.
2
with
:
step
:
finish
deployment_id
:
${{ steps.deployment.outputs.deployment_id }}
token
:
${{ secrets.GITHUB_TOKEN }}
env
:
staging
env
:
production
status
:
${{ job.status }}
env_url
:
'
https://${{
steps.deployment_params.outputs.version
}}-dot-httpbingo.uc.r.appspot.com'
logs
:
'
https://console.cloud.google.com/logs/viewer?project=${{
secrets.GCP_PROJECT_ID
}}&resource=gae_app%2Fmodule_id%2Fdefault%2Fversion_id%2F${{
steps.deployment_params.outputs.version
}}'
env_url
:
'
https://httpbingo.org'
This diff is collapsed.
Click to expand it.
Makefile
+
13
−
5
View file @
c013cc1d
...
...
@@ -95,11 +95,21 @@ lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
run
:
build
$(
DIST_PATH
)
/go-httpbin
watch
:
$(TOOL_REFLEX)
reflex
-s
-r
'\.(go|html)$$'
make run
# =============================================================================
# deploy to fly.io
# =============================================================================
deploy
:
flyctl deploy
--strategy
=
rolling
# =============================================================================
# deploy to google cloud run
# =============================================================================
deploy
:
gcloud-auth imagepush
deploy
-cloud-run
:
gcloud-auth imagepush
$(
GCLOUD_COMMAND
)
beta run deploy
\
$(
GCLOUD_PROJECT
)
\
--image
=
$(
DOCKER_TAG_GCLOUD
)
\
...
...
@@ -109,8 +119,9 @@ deploy: gcloud-auth imagepush
--region
=
$(
GCLOUD_REGION
)
\
--allow-unauthenticated
\
--platform
=
managed
$(
GCLOUD_COMMAND
)
run services update-traffic
--to-latest
stagedeploy
:
gcloud-auth imagepush
stagedeploy
-cloud-run
:
gcloud-auth imagepush
$(
GCLOUD_COMMAND
)
beta run deploy
\
$(
GCLOUD_PROJECT
)
\
--image
=
$(
DOCKER_TAG_GCLOUD
)
\
...
...
@@ -126,9 +137,6 @@ gcloud-auth:
@$(
GCLOUD_COMMAND
)
auth list |
grep
'^\*'
|
grep
-q
$(
GCLOUD_ACCOUNT
)
||
$(
GCLOUD_COMMAND
)
auth login
$(
GCLOUD_ACCOUNT
)
@$(
GCLOUD_COMMAND
)
auth print-access-token | docker login
-u
oauth2accesstoken
--password-stdin
https://gcr.io
watch
:
$(TOOL_REFLEX)
reflex
-s
-r
'\.(go|html)$$'
make run
# =============================================================================
# docker images
...
...
This diff is collapsed.
Click to expand it.
fly.toml
0 → 100644
+
21
−
0
View file @
c013cc1d
app
=
"httpbingo"
[[services]]
internal_port
=
8080
protocol
=
"tcp"
[services.concurrency]
hard_limit
=
25
soft_limit
=
20
[[services.ports]]
handlers
=
[
"http"
]
port
=
"80"
[[services.ports]]
handlers
=
[
"tls"
,
"http"
]
port
=
"443"
[[services.tcp_checks]]
interval
=
10000
timeout
=
2000
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment