Skip to content

Commit

Permalink
GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Mar 4, 2024
1 parent 557d462 commit 8930dc1
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 5
assignees:
- "paulyhedral"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
74 changes: 74 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Debug

on:
create:
tags:
- '*'
release:
types:
- published
- created
push:
branches:
- '*'

jobs:
debug:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
- name: Get current date
id: getbuilddate
run: |
echo "::set-output name=date::$(date -u)"
echo "::set-output name=isodate::$(date -u '+%Y-%m-%dT%H:%M:%S')"
echo "::set-output name=tagdate::$(date -u '+%Y%m%d%H%M%S')"
echo "::set-output name=timestamp::$(date -u '+%s')"
- name: 'Get Previous tag'
id: previoustag
uses: actions-ecosystem/action-get-latest-tag@v1
with:
semver_only: true
initial_version: v0.0.0
with_initial_version: true
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
registry.sweetrpg.com/sweetrpg-main-web
tags: |
type=raw,value=latest
type=raw,value=${{ steps.previoustag.outputs.tag }}
type=raw,value=${{ steps.getbuilddate.outputs.date }}
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
91 changes: 91 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Docker Build

concurrency: docker

on:
push:
branches:
- develop
paths:
- Dockerfile
- scripts/entrypoint.sh
workflow_run:
workflows: ["CI"]
branches: [develop]
types:
- completed

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: "Get Previous tag"
id: previoustag
uses: actions-ecosystem/action-get-latest-tag@v1
with:
semver_only: true
initial_version: v0.0.0
with_initial_version: true
- name: Get current date
id: getbuilddate
run: |
echo "::set-output name=date::$(date -u)"
echo "::set-output name=isodate::$(date -u '+%Y-%m-%dT%H:%M:%S')"
echo "::set-output name=tagdate::$(date -u '+%Y%m%d%H%M%S')"
echo "::set-output name=timestamp::$(date -u '+%s')"
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/sweetrpg/catalog-api
tags: |
type=raw,value=latest
type=raw,value=${{ steps.previoustag.outputs.tag }}
type=raw,value=${{ steps.getbuilddate.outputs.tagdate }}
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
# context: .
push: true
no-cache: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BUILD_NUMBER=${{ github.run_number }}
BUILD_JOB=${{ github.job }}
BUILD_SHA=${{ github.sha }}
BUILD_DATE=${{ steps.getbuilddate.outputs.isodate }}
BUILD_VERSION=${{ steps.previoustag.outputs.tag }}
# tags: registry.sweetrpg.com/sweetrpg-catalog-api:latest
# - name: Scan image
# uses: sysdiglabs/scan-action@v1
# with:
# image-tag: registry.sweetrpg.com/sweetrpg-catalog-api:latest
# sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
with:
environment: ${{ vars.SENTRY_ENV }}
98 changes: 98 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

concurrency: ci-${{ github.ref }}

on:
push:
branches: [develop]
paths:
- "src/**"
- "tests/**"
- setup.cfg
- setup.py
- tox.ini
- "requirements/**"
- "docs/**"
workflow_run:
workflows: ["Update Requirements"]
types: [completed]

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
concurrency: ci
strategy:
fail-fast: false
matrix:
include:
- {
name: Linux,
python: "3.10",
os: ubuntu-latest,
tox: py310,
}
# - {
# name: Windows,
# python: "3.10",
# os: windows-latest,
# tox: py310,
# }
# - { name: Mac, python: "3.10", os: macos-latest, tox: py310 }
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: update-pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: get-pip-cache-dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: cache-pip
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }}
- name: install-utils
run: pip install tox
- name: tests
run: tox -e ${{ matrix.tox }}

# docs:
# needs: [tests]
# runs-on: ubuntu-latest
# concurrency: docs
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - name: install-deps
# run: pip install -r requirements/docs.txt
# - name: make-docs
# run: cd docs && make html
# - name: publish-docs
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs/_build/html

tag:
needs: [tests]
runs-on: ubuntu-latest
concurrency: publish
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: publish
uses: relekang/python-semantic-release@master
with:
additional_options: "--patch"
github_token: ${{ secrets.GITHUB_TOKEN }}
repository_username: __token__
repository_password: ${{ secrets.PYPI_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/python-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: PR

concurrency: pr-${{ github.ref }}

on:
pull_request:
branches: [develop]
paths:
- "src/**"
- "tests/**"
- setup.cfg
- setup.py
- tox.ini
- "requirements/**"
- "docs/**"

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {
name: Linux,
python: "3.10",
os: ubuntu-latest,
tox: py310,
}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: update-pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: get-pip-cache-dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: cache-pip
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }}
- name: install-utils
run: pip install tox
- name: tests
run: tox -e ${{ matrix.tox }}
37 changes: 37 additions & 0 deletions .github/workflows/python-update-reqs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update Requirements

on:
workflow_dispatch:
repository_dispatch:
types:
- model-core-published
- api-core-published
- catalog-objects-published
- db-published
schedule:
- cron: "0 1 * * 1"
push:
branches:
- develop
paths:
- "requirements/*.in"
- setup.py

jobs:
update-reqs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: update-reqs
run: |
pip install -U wheel setuptools pip-tools
git config --global user.email "[email protected]"
git config --global user.name "SweetRPG Requirement Updater"
git checkout ${{ github.head_ref || github.ref_name }}
scripts/update-requirements.sh
git add requirements/*.txt
git commit -m "Update requirements"
git push origin

0 comments on commit 8930dc1

Please sign in to comment.