feat: first release (3nd attempt) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release image to GHCR | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: True | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: | | |
$(cat Dockerfile | grep "pip install" | cut -f2- -d " ") | |
- name: Install pylint | |
run: | | |
python -m pip install pylint==3.1.0 black==24.3.0 | |
# - name: Lint Python code with black | |
# run: | | |
# black --check --skip-string-normalization --line-length 120 bot | |
- name: Lint Python code | |
run: | | |
pylint --disable=R,C,W1203,W0105 bot/main.py | |
- name: Lint Dockerfile with hadolint | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
failure-threshold: error | |
ignore: DL3008,SC3009,DL3013 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: minor | |
- name: Login to GitHub Container Registry | |
# do this step only on push to main and do not run for pull request | |
if: github.event_name == 'push' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image and push to registry | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
# push to registry when merge to main | |
push: ${{ github.ref == 'refs/heads/main' }} | |
no-cache: true | |
tags: | | |
ghcr.io/yurnov/explosion-notifier:master | |
ghcr.io/yurnov/explosion-notifier:${{ steps.tag_version.outputs.new_tag }} |