diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..2eeb646 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,59 @@ +name: Market Maker Keeper - Build and Push + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + branch: + description: 'Branch to build and deploy' + required: false + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Docker Registry + uses: docker/login-action@v1 + with: + registry: registry.hamdocker.ir/bitex + username: ${{ secrets.HAMRAVESH_REGISTRY_USER }} + password: ${{ secrets.HAMRAVESH_REGISTRY_PASS }} + + - name: Get the branch name + id: get-branch-name + run: | + if [[ $GITHUB_HEAD_REF ]]; then + BRANCH_NAME=${GITHUB_HEAD_REF} + else + BRANCH_NAME=${GITHUB_REF#refs/heads/} + fi + BRANCH_NAME=$(echo ${BRANCH_NAME} | sed 's/\//-/g' | cut -c 1-30) + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV + + - name: Set Docker image tag + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + TAG=${GITHUB_REF#refs/tags/} + else + TAG=$(echo ${GITHUB_SHA::8}) + fi + echo "TAG=$TAG" >> $GITHUB_ENV + + - name: Build and push market-make-keeper + uses: docker/build-push-action@v2 + with: + file: Dockerfile + context: . + push: true + tags: registry.hamdocker.ir/bitex/market-maker-keeper:${{ env.TAG }}