diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..d02734a --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,87 @@ +name: build_and_push + +on: + pull_request: + push: + branches: [master] + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +jobs: + + build_docker: + name: Build Docker image + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build Docker image and save it to a file + run: | + DOCKER_REPO=vivareal make docker_image + mkdir -p /tmp/docker-cache + docker save -o /tmp/docker-cache/x9.tar vivareal/x9:latest + - name: Cache Docker image for further jobs in this workflow run + uses: actions/upload-artifact@v2 + with: + name: docker-image-cache + path: /tmp/docker-cache/ + retention-days: 1 + + push_master_docker: + if: github.ref == 'refs/heads/master' + name: Push Docker image with tag master + needs: build_docker + runs-on: ubuntu-20.04 + env: + DOCKER_REPO: vivareal + DOCKER_IMAGE_VERSION: master + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Download cached Docker image + uses: actions/download-artifact@v2 + with: + name: docker-image-cache + path: /tmp/docker-cache/ + - name: Load Docker image and tag it as master + run: | + docker load < /tmp/docker-cache/x9.tar + make docker_tag + - uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Push Docker image with tag master + run: make docker_push + + push_release_docker: + if: "startsWith(github.ref, 'refs/tags/v')" + name: Push Docker image according to release + needs: build_docker + runs-on: ubuntu-20.04 + env: + DOCKER_REPO: vivareal + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Download cached Docker image + uses: actions/download-artifact@v2 + with: + name: docker-image-cache + path: /tmp/docker-cache/ + - name: Load Docker image and tag it according to current release + run: | + docker load < /tmp/docker-cache/x9.tar + make docker_tag DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/tags/} + - uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Push Docker image with release tag + run: make docker_push DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/tags/} + - name: Push Docker image with latest tag if this version is stable + run: | + if [[ "${{ github.ref }}" =~ "^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$" ]]; then + make docker_push DOCKER_IMAGE_VERSION=latest + fi + diff --git a/circle.yml b/circle.yml deleted file mode 100644 index fe77195..0000000 --- a/circle.yml +++ /dev/null @@ -1,29 +0,0 @@ -machine: - services: - - docker - -dependencies: - override: - - docker login -e $DOCKER_EMAIL -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - - make docker_build - -deployment: - master: - branch: master - commands: - - make docker_image - - make docker_tag DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=master - - make docker_push DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=master - hub: - tag: /^v[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)(\.[0-9])*$/ - commands: - - make docker_image - - make docker_tag DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=$CIRCLE_TAG - - make docker_push DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=$CIRCLE_TAG - stable: - tag: /^v[0-9]+\.[0-9]+\.[0-9]+$/ - commands: - - make docker_image - - make docker_tag DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=$CIRCLE_TAG - - make docker_push DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=$CIRCLE_TAG - - make docker_push DOCKER_REPO=$DOCKER_REPO DOCKER_IMAGE_VERSION=latest