Skip to content

Release-Robot

Release-Robot #16

Workflow file for this run

name: Release-Robot
on:
release:
types: [ published, edited ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# debug
- name: Dump Env
run: env | sort
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# GIT_TAG=$(git describe --exact-match --abbrev=0 --tags "${COMMIT}" 2> /dev/null || true)
# https://github.com/actions/actions-runner-controller/blob/acbce4b70ad1cf719f3bab94e127ca38a1576228/hack/make-env.sh
# GIT_TAG=${GITHUB_REF/refs\/tags\//}
# 这个方式在commit没有tag时,结果类似于: refs/heads/main
- name: Prepare Env
id: Prepare
run: |
GIT_TAG=${GITHUB_REF/refs\/tags\//}
GIT_COMMIT=$(git rev-parse HEAD)
echo "GIT_COMMIT=$GIT_COMMIT$">> $GITHUB_ENV
echo "GIT_TAG=$GIT_TAG">> $GITHUB_ENV
echo "GITHUB_RUN_URL=$github_run_url">> $GITHUB_ENV
echo "GIT_BRANCH=`git branch --show-current`" >> $GITHUB_ENV
- name: Robot Post Message
env:
tag_name: ${{ github.event.release.tag_name }}
chat_id: ${{ secrets.TG_CI_CHAT_ID }}
bot_token: ${{ secrets.TG_CI_BOT_TOKEN }}
github_user: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# github_release: ${{ toJson(github.event.release) }}
run: |
echo "${{ toJson(github) }}"> github_context.txt
python robot.py -e release