Skip to content

Merge branch 'development' #170

Merge branch 'development'

Merge branch 'development' #170

Workflow file for this run

name: CI
on:
push:
branches:
- master
- development
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
IMAGE_NAME: expl-bot
jobs:
# Run tests.
test:
runs-on: ubuntu-latest
container: node:16
defaults:
run:
shell: bash
services:
postgres:
image: postgres:12-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm ci
- run: npm run test
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@postgres:5432/postgres
- run: npm install -g zx
- name: Generate Telegram message
if: ${{ always() }}
id: telegram_message
run: |
const message = []
const jobStatus = `${{ job.status }}`
const commitMessage = `${{ github.event.head_commit.message }}`
const sha = `${{ github.sha }}`
message.push(jobStatus == 'success' ? '✅' : '❌')
message.push(`"${commitMessage}"`)
message.push(`([\#${sha.substring(0,7)}](https://github.com/${process.env.GITHUB_REPOSITORY}/commit/${sha}))`)
message.push(`@ \`${process.env.GITHUB_REF.replace("refs/heads/", "")}\``)
message.push(`by *${process.env.GITHUB_ACTOR}*`)
const output = `::set-output name=message::${message.join(' ')}`
await $`echo ${output}`
shell: zx {0}
- name: Send notification
if: ${{ always() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: ${{ steps.telegram_message.outputs.message }}
format: markdown
disable_web_page_preview: true
build_and_push:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to GHCR
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}