hotfix: bump package version #144
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: CI | |
on: | |
push: | |
branches: [master] | |
tags: [v*] | |
pull_request: | |
branches: [master] | |
pull_request_target: | |
branches: [master] | |
jobs: | |
lint: | |
name: Linter | |
runs-on: ubuntu-latest | |
if: | | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') | |
timeout-minutes: 10 | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11.11 | |
- name: Cache pre-commit hooks | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|py3.11|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Cache PyPI | |
uses: actions/cache@v3 | |
with: | |
key: pip-lint-${{ hashFiles('requirements/*.txt') }} | |
path: ~/.cache/pip | |
restore-keys: | | |
pip-lint- | |
- name: Install dependencies | |
uses: py-actions/py-dependency-install@v3 | |
with: | |
path: requirements/python-test.txt | |
- name: Run linters | |
run: | | |
make lint | |
- name: Save app version | |
id: version | |
run: | | |
ver=$(python -c 'from modules.version import __version__ as v; print(v)') | |
echo "version=${ver}" >> "$GITHUB_OUTPUT" | |
deploy: | |
name: Deploy on Github container registry | |
needs: [lint] | |
runs-on: ubuntu-latest | |
# Run only on pushing a tag | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
steps: | |
- name: Sanity check for tag and version | |
run: | | |
if [ "refs/tags/v${{ needs.lint.outputs.version }}" != "${{ github.ref }}" ] | |
then | |
echo "Tag ${{ github.ref }} mismatches with ${{ needs.lint.outputs.version }}" | |
exit 1 | |
else | |
echo "Tag matches version ${{ needs.lint.outputs.version }}" | |
fi | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to ghcr | |
uses: docker/login-action@v2.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Image | |
run: | | |
docker build \ | |
-t "ghcr.io/neuro-inc/job-deploy-app:${VERSION}" \ | |
-t "ghcr.io/neuro-inc/job-deploy-app:pipelines" \ | |
. | |
env: | |
VERSION: ${{ needs.lint.outputs.version }} | |
- name: Push Image | |
run: | | |
docker push --all-tags ghcr.io/neuro-inc/job-deploy-app |