diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..ff27938e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: Run tests on PRs and commits + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + workflow_dispatch: + +env: + BOT_ID: 916ccfd76a7fda25c74d09e1d5 + LEAGUE_ID: 164483 + TEST_TAG: user/test_build:test + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build container + uses: docker/build-push-action@v2 + with: + push: false + context: . + load: true + tags: ${{ env.TEST_TAG }} + + - name: Run image against tests + run: docker run ${{ env.TEST_TAG }} python /usr/src/ff_bot/setup.py test diff --git a/.github/workflows/publish_image.yaml b/.github/workflows/publish_image.yaml new file mode 100644 index 00000000..558c2afa --- /dev/null +++ b/.github/workflows/publish_image.yaml @@ -0,0 +1,52 @@ +name: Publish image on commit or published release + +on: + push: + branches: + - master + - main + release: + types: + - published + +jobs: + push-image: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Set tag name for releases + if: ${{ github.event_name == 'release' }} + run: echo "TAG=ghcr.io/${GITHUB_REPOSITORY,,}:${GITHUB_REF##*/}" >>${GITHUB_ENV} + + - name: Set tag name for commits + if: ${{ github.event_name == 'push' }} + run: echo "TAG=ghcr.io/${GITHUB_REPOSITORY,,}:${{ github.sha }}" >>${GITHUB_ENV} + + - name: Build image + uses: docker/build-push-action@v2 + with: + load: true + push: false + tags: ${{ env.TAG }} + + - name: Test image + run: docker run ${{ env.TAG }} python /usr/src/ff_bot/setup.py test + + - name: Push image to registry + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ env.TAG }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bf7b6497..00000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -sudo: required - -language: python -python: - - "3.8" - - "3.9" - -services: - - docker - -install: - - pip3 install -r requirements.txt - -script: - - docker build -t test_build . - - docker run test_build python3 /usr/src/ff_bot/setup.py test - -env: - - BOT_ID=916ccfd76a7fda25c74d09e1d5 LEAGUE_ID=164483 diff --git a/Dockerfile b/Dockerfile index 09b18142..92d9f2e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:latest +FROM python:3.9.9-slim-bullseye # Install app ADD . /usr/src/ff_bot