2020-08-31 20:48:46 +00:00
|
|
|
name: Dicebot CI
|
2020-08-31 20:24:57 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
# Publish `v1.2.3` tags as releases.
|
|
|
|
tags:
|
|
|
|
- v*
|
|
|
|
|
|
|
|
# Run tests for any PRs.
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
2020-08-31 20:48:46 +00:00
|
|
|
IMAGE_NAME: chronicle-dicebot
|
|
|
|
CARGO_TERM_COLOR: always
|
2020-08-31 20:24:57 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-08-31 20:48:46 +00:00
|
|
|
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
|
|
|
|
|
2020-08-31 21:35:19 +00:00
|
|
|
docker_push_latest:
|
2020-08-31 20:57:47 +00:00
|
|
|
needs: build_and_test
|
2020-08-31 20:24:57 +00:00
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
2020-08-31 22:30:44 +00:00
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
2020-08-31 20:24:57 +00:00
|
|
|
|
|
|
|
steps:
|
2020-08-31 21:35:19 +00:00
|
|
|
- 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 }}
|
2020-08-31 22:06:35 +00:00
|
|
|
repository: projectmoon/chronicle-dicebot
|
2020-08-31 21:35:19 +00:00
|
|
|
tags: latest
|
|
|
|
|
|
|
|
docker_push_tag:
|
|
|
|
needs: build_and_test
|
2020-08-31 20:24:57 +00:00
|
|
|
|
2020-08-31 21:35:19 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-08-31 22:30:44 +00:00
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
2020-08-31 20:24:57 +00:00
|
|
|
|
2020-08-31 21:35:19 +00:00
|
|
|
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 }}
|
2020-08-31 22:06:35 +00:00
|
|
|
repository: projectmoon/chronicle-dicebot
|
2020-08-31 21:35:19 +00:00
|
|
|
tag_with_ref: true
|