name: Dicebot CI on: push: branches: - master # Publish `v1.2.3` tags as releases. tags: - v* # Run tests for any PRs. pull_request: env: IMAGE_NAME: chronicle-dicebot CARGO_TERM_COLOR: always jobs: build_and_test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose docker_push_latest: needs: build_and_test runs-on: ubuntu-latest if: github.event_name == 'push' steps: - name: Checkout code uses: actions/checkout@v2 - name: Build and push Docker images uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: projectmoon/chronicle-dicebot tags: latest push: ${{ github.ref == 'refs/heads/master' }} docker_push_tag: needs: build_and_test runs-on: ubuntu-latest if: github.event_name == 'push' steps: - name: Checkout code uses: actions/checkout@v2 - name: Build and push Docker images uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: projectmoon/chronicle-dicebot tags: latest tag_with_ref: true push: ${{ startsWith(github.ref, 'refs/tags/') }}