Skip to content

Commit

Permalink
Merge pull request #74 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 2.3.1 - use GitHub Actions
  • Loading branch information
briskt authored Mar 1, 2024
2 parents ce9367f + 639c681 commit 4993ce1
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Whitelist required files
!.env.encrypted
!codeship/*
!scripts/*
!lambda/*
!server/*
!u2fsimulator/*
Expand Down
File renamed without changes.
69 changes: 69 additions & 0 deletions .github/workflows/test-deploy-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test, Deploy, Publish

on:
push:

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ vars.AWS_REGION }}
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test
run: docker-compose -f actions-services.yml run --rm test ./scripts/test.sh

deploy:
name: Deploy to AWS Lambda
needs: tests
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ vars.AWS_REGION }}
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
STG_LAMBDA_ROLE: ${{ vars.STG_LAMBDA_ROLE }}
STG_API_KEY_TABLE: ${{ vars.STG_API_KEY_TABLE }}
STG_WEBAUTHN_TABLE: ${{ vars.STG_WEBAUTHN_TABLE }}
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
PRD_LAMBDA_ROLE: ${{ vars.PRD_LAMBDA_ROLE }}
PRD_API_KEY_TABLE: ${{ vars.PRD_API_KEY_TABLE }}
PRD_WEBAUTHN_TABLE: ${{ vars.PRD_WEBAUTHN_TABLE }}

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy
run: docker-compose -f actions-services.yml run --rm app ./scripts/deploy.sh

build-and-publish:
name: Build and Publish
needs: tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ bootstrap
dockercfg

# credentials and other env files
aws.env
*.aes
local.env
.env
*.env
.cert/

# dev tools metadata
Expand Down
44 changes: 44 additions & 0 deletions actions-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3"

services:
test:
build: .
environment:
AWS_ENDPOINT: dynamo:8000
AWS_DISABLE_SSL: "true"
API_KEY_TABLE: ApiKey
WEBAUTHN_TABLE: WebAuthn
LAMBDA_ROLE: placeholder
AWS_REGION: $AWS_REGION
GITHUB_REF_NAME: $GITHUB_REF_NAME
STG_AWS_ACCESS_KEY_ID: $STG_AWS_ACCESS_KEY_ID
STG_AWS_SECRET_ACCESS_KEY: $STG_AWS_SECRET_ACCESS_KEY
PRD_AWS_ACCESS_KEY_ID: $PRD_AWS_ACCESS_KEY_ID
PRD_AWS_SECRET_ACCESS_KEY: $PRD_AWS_SECRET_ACCESS_KEY
depends_on:
- dynamo

app:
build: .
working_dir: /src
environment:
AWS_REGION: $AWS_REGION
GITHUB_REF_NAME: $GITHUB_REF_NAME
STG_AWS_ACCESS_KEY_ID: $STG_AWS_ACCESS_KEY_ID
STG_AWS_SECRET_ACCESS_KEY: $STG_AWS_SECRET_ACCESS_KEY
STG_LAMBDA_ROLE: $STG_LAMBDA_ROLE
STG_API_KEY_TABLE: $STG_API_KEY_TABLE
STG_WEBAUTHN_TABLE: $STG_WEBAUTHN_TABLE
PRD_AWS_ACCESS_KEY_ID: $PRD_AWS_ACCESS_KEY_ID
PRD_AWS_SECRET_ACCESS_KEY: $PRD_AWS_SECRET_ACCESS_KEY
PRD_LAMBDA_ROLE: $PRD_LAMBDA_ROLE
PRD_API_KEY_TABLE: $PRD_API_KEY_TABLE
PRD_WEBAUTHN_TABLE: $PRD_WEBAUTHN_TABLE

dynamo:
image: amazon/dynamodb-local
environment:
AWS_ACCESS_KEY_ID: abc123
AWS_SECRET_ACCESS_KEY: abc123
AWS_DEFAULT_REGION: us-east-1
command: "-jar DynamoDBLocal.jar -sharedDb"
29 changes: 0 additions & 29 deletions codeship-services.yml

This file was deleted.

26 changes: 0 additions & 26 deletions codeship-steps.yml

This file was deleted.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.11.0
golang.org/x/crypto v0.17.0
)

require (
Expand All @@ -26,7 +26,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/sys v0.15.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcY
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand All @@ -63,8 +63,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions codeship/deploy.sh → scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
"$DIR"/build.sh

# export appropriate env vars
if [ "${CI_BRANCH}" == "develop" ];
if [ "${GITHUB_REF_NAME}" == "develop" ];
then
STAGE="dev"
export AWS_ACCESS_KEY_ID="${STG_AWS_ACCESS_KEY_ID}"
Expand All @@ -21,7 +21,7 @@ then
export LAMBDA_ROLE="${STG_LAMBDA_ROLE}"
export API_KEY_TABLE="${STG_API_KEY_TABLE}"
export WEBAUTHN_TABLE="${STG_WEBAUTHN_TABLE}"
elif [ "${CI_BRANCH}" == "main" ];
elif [ "${GITHUB_REF_NAME}" == "main" ];
then
STAGE="production"
export AWS_ACCESS_KEY_ID="${PRD_AWS_ACCESS_KEY_ID}"
Expand All @@ -32,7 +32,7 @@ then
export API_KEY_TABLE="${PRD_API_KEY_TABLE}"
export WEBAUTHN_TABLE="${PRD_WEBAUTHN_TABLE}"
else
echo "deployments only happen from develop and main branches (branch: ${CI_BRANCH})"
echo "deployments only happen from develop and main branches (branch: ${GITHUB_REF_NAME})"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion codeship/test.sh → scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
set -x

# export appropriate AWS credentials for `serverless info`
if [ "${CI_BRANCH}" == "main" ];
if [ "${GITHUB_REF_NAME}" == "main" ];
then
STAGE="production"
export AWS_ACCESS_KEY_ID="${PRD_AWS_ACCESS_KEY_ID}"
Expand Down

0 comments on commit 4993ce1

Please sign in to comment.