Skip to content

fix order, add config #56

fix order, add config

fix order, add config #56

Workflow file for this run

name: Continuous Integration and Deployment
on:
pull_request:
branches: [develop]
push:
branches: [develop]
env:
GITHUB_COMMIT_ID: ${{github.sha}}
jobs:
unit-test:
environment: development
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: |
go test ./test -v
build-and-deploy:
needs: [unit-test]
environment: development
if: github.event_name == 'push' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Bump version and push tag
id: tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Create env file'
run: |
echo "${{ secrets.ENV_FILE }}" > ./config/config.yml
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{vars.REPOSITORY}}:latest, ${{vars.REPOSITORY}}:${{ steps.tag.outputs.new_tag }}
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SECRET_KEY }}
port: 22
script: |
if [ -d "${{ secrets.DIRECTORY }}" ]; then
echo "Directory exists, pulling from repo";
cd "${{ secrets.DIRECTORY }}";
git pull origin develop;
else
echo "Directory does not exist, cloning repo";
git clone "https://github.com/${{ github.repository }}" "${{ secrets.DIRECTORY }}";
cd "${{ secrets.DIRECTORY }}";
fi
echo "Installing dependencies";
docker pull ${{vars.REPOSITORY}}:${{ steps.tag.outputs.new_tag }};
docker rm -f erp-dev;
docker run -d --name erp-dev -p ${{secrets.EXPORT_PORT}}:${{secrets.CONTAINER_PORT}} ${{vars.REPOSITORY}}:${{ steps.tag.outputs.new_tag }};