name: Build and Deploy on: push: branches: - main env: REGISTRY: localhost:9999 IMAGE_NAME: ${{ secrets.PROJECT_NAME }} jobs: cleaning: runs-on: go steps: - name: Cleanup run: | docker stop $IMAGE_NAME || true docker rm $IMAGE_NAME || true docker container prune -f docker image prune -af build_image: runs-on: go container: null needs: cleaning steps: - uses: actions/checkout@v4 - name: Copy env run: | echo "${{ secrets.ENV_FILE }}" > .env cat .env - name: Build & Push run: | docker build -t $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }} . docker push $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }} deploy: runs-on: go container: null needs: build_image steps: - name: Deploy container run: | docker run -d \ --name $IMAGE_NAME \ --memory="50m" \ --cpus="0.1" \ --restart always \ -p 9997:3000 \ $REGISTRY/$IMAGE_NAME:${{ gitea.run_number }}