Skip to content

Commit

Permalink
Merge pull request #563 from dadosjusbr/continuous-delivery
Browse files Browse the repository at this point in the history
Continuous delivery & Continuous integration
  • Loading branch information
danielfireman authored Oct 9, 2023
2 parents 8f486c4 + 3c141c1 commit 00e6cce
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 65 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Continuous Integration

on:
pull_request:
jobs:
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.0

- name: Install Dependencies
run: go mod download

- name: Testing code
run: |
if go test ./...; then
echo "All tests have passed✅"
else
echo "Test failed❌"
exit 1
fi
51 changes: 51 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Continuous Delivery

on:
schedule:
- cron: "45 2 * * 2"
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_ENVIRONMENT_NAME: ${{ secrets.AWS_ENVIRONMENT_NAME }}
AWS_APPLICATION_NAME: ${{ secrets.AWS_APPLICATION_NAME }}
steps:
- uses: actions/checkout@v2
- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.0

- name: Install Dependencies
run: go mod download

- name: Build application
run: go build -o api

- name: Install EB CLI using pip
run: |
python -m pip install --upgrade pip
pip install awsebcli
- name: Initialize EB Environment
run: (echo "1"; echo "n") | eb init -r ${{ env.AWS_DEFAULT_REGION }} ${{ env.AWS_APPLICATION_NAME }}

- name: Set EB Environment
run: eb use ${{ env.AWS_ENVIRONMENT_NAME }} -r ${{ env.AWS_DEFAULT_REGION }}

- name: Deploy to EB
run: |
if eb deploy; then
echo "Deployment succeeded✅"
else
echo "Deployment failed❌"
exit 1
fi
64 changes: 0 additions & 64 deletions .github/workflows/docker-publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ require (
)

require (
github.com/aws/aws-sdk-go v1.44.190
github.com/aws/aws-sdk-go v1.45.23
github.com/golang/protobuf v1.5.2 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/lib/pq v1.10.7 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
github.com/aws/aws-sdk-go v1.44.127/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/aws/aws-sdk-go v1.44.190 h1:QC+Pf/Ooj7Waf2obOPZbIQOqr00hy4h54j3ZK9mvHcc=
github.com/aws/aws-sdk-go v1.44.190/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.45.23 h1:0xRQw5fsFMpisaliDZ8iUZtw9w+3YjY9/UwUGRbB/i4=
github.com/aws/aws-sdk-go v1.45.23/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down

0 comments on commit 00e6cce

Please sign in to comment.