Skip to content

CI

CI #327

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: CI
on:
push:
branches: [ "main" ]
schedule:
- cron: '0 20 * * *'
workflow_dispatch:
env:
USERNAME: ssttkkl
REGISTRY: docker.io
IMAGE_NAME: ssttkkl/bot-kuraku
jobs:
poetry-update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Poetry Update (bot)
run: |
poetry update
working-directory: ./bot
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automated Poetry Update
build:
needs: poetry-update
strategy:
matrix:
image: ['bot']
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Pull
run: |
git pull origin main
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.1.1
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}-${{ matrix.image }}
tags: |
type=raw,value=latest
type=schedule,pattern={{date 'YYYYMMDD'}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: ./${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Depoly through SSH
uses: nekiro/ssh-job@main
with:
host: ${{ secrets.DEPLOY_HOST }}
key: ${{ secrets.DEPLOY_PRI_KEY }}
user: ${{ secrets.DEPLOY_USER }}
command: |
cd ~/bot-kuraku
./ci.sh