From e1a849c310997de1412701fb62d5c24b5e4d1b15 Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Sun, 14 Nov 2021 09:40:24 +0100 Subject: [PATCH] replace circleci with github workflows --- .circleci/config.yml | 51 ----------------------------------- .github/workflows/publish.yml | 48 +++++++++++++++++++++++++++++++++ Dockerfile | 5 +--- 3 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/publish.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index bdf6bf3..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: 2 -jobs: - build_latest: - docker: - - image: circleci/golang:1.17 - working_directory: ~/twhelpdcbot - steps: - - checkout - - setup_remote_docker - # start proprietary DB using private Docker image - # with credentials stored in the UI - - run: | - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - # build the application image - - run: docker build -t $DOCKER_LOGIN/twhelp-dcbot:latest . - # deploy the image - - run: docker push $DOCKER_LOGIN/twhelp-dcbot:latest - build_version: - docker: - - image: circleci/golang:1.17 - working_directory: ~/twhelpdcbot - steps: - - checkout - - setup_remote_docker - # start proprietary DB using private Docker image - # with credentials stored in the UI - - run: | - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - # build the application image - - run: docker build -t $DOCKER_LOGIN/twhelp-dcbot:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//') . - # deploy the image - - run: docker push $DOCKER_LOGIN/twhelp-dcbot:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//') -workflows: - version: 2 - deploy_latest: - jobs: - - build_latest: - context: TWHelp - filters: - branches: - only: - - master - deploy_version: - jobs: - - build_version: - context: TWHelp - filters: - tags: - only: /^v.*/ - branches: - ignore: /.*/ diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6f3f178 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: Build and push to registry + +on: + push: + tags: + - '*' + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.REGISTRY_LOGIN }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: . + build-args: | + VERSION=${{ steps.get_version.outputs.VERSION }} + tags: | + ${{ secrets.REGISTRY_NAME }}/twhelp-dcbot:latest + ${{ secrets.REGISTRY_NAME }}/twhelp-dcbot:${{ steps.get_version.outputs.VERSION }} + file: ./Dockerfile + push: true diff --git a/Dockerfile b/Dockerfile index 459436e..6608a59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,4 @@ ENV APP_MODE=production ENV GIN_MODE=release EXPOSE 8080 -ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait ./wait -RUN chmod +x ./wait - -CMD ./wait && ./twhelpdcbot +CMD ./twhelpdcbot