Skip to content

remove disclamer and fix backoff #56

remove disclamer and fix backoff

remove disclamer and fix backoff #56

Workflow file for this run

name: Deploy to Amazon EC2
on:
workflow_dispatch:
push:
branches:
- main
- dev
env:
IMAGE_REPO: stepancons
IMAGE_TAG: ${{ github.sha }}
permissions:
contents: read
jobs:
test:
name: Test all application
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20.3'
- name: Build
run: go build -v $(go list -f '{{.Dir}}/...' -m | xargs)
- name: Test
run: go test -v $(go list -f '{{.Dir}}/...' -m | xargs)
# Push and deploy dev
push-dev:
needs: test
name: Push Dev to DockerHub
runs-on: ubuntu-latest
environment: dev
if: github.event.ref == 'refs/heads/dev' || github.event.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build, tag, and push image to Docker Hub
id: build-image
env:
IMAGE_REPO: ${{ env.IMAGE_REPO }}
IMAGE_TAG: dev
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
chmod +x ./scripts/push-to-dockerhub.sh && ./scripts/push-to-dockerhub.sh
deploy-dev:
needs: push-dev
name: Deploy Dev to EC2
runs-on: ubuntu-latest
environment: dev
if: github.event.ref == 'refs/heads/dev' || github.event.ref == 'refs/heads/main'
steps:
- name: Checkout the files
uses: actions/checkout@v3
- name: Copy code to server and run dev
env:
BRANCH: ${{ github.ref_name }}
ENVIRONMENT: dev
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.TARGET }}
run: |
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key
chmod +x ./scripts/deploy.sh && ./scripts/deploy.sh
# Push and deploy prod
push-prod:
needs: deploy-dev
name: Push Prod to DockerHub
runs-on: ubuntu-latest
environment: dev
if: github.event.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build, tag, and push image to Docker Hub
id: build-image
env:
IMAGE_REPO: ${{ env.IMAGE_REPO }}
IMAGE_TAG: prod
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
chmod +x ./scripts/push-to-dockerhub.sh && ./scripts/push-to-dockerhub.sh
deploy-prod:
needs: push-prod
name: Deploy Prod to EC2
runs-on: ubuntu-latest
environment: dev
if: github.event.ref == 'refs/heads/main'
steps:
- name: Checkout the files
uses: actions/checkout@v3
- name: Copy code to server and run prod
env:
BRANCH: ${{ github.ref_name }}
ENVIRONMENT: prod
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.TARGET }}
run: |
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key
chmod +x ./scripts/deploy.sh && ./scripts/deploy.sh