Fix: listen on 0.0.0.0 by env variable #10
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: generate-badges | |
on: | |
push: | |
branches: [ "main" ] | |
permissions: | |
contents: write | |
jobs: | |
generate-badges: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
- name: Fetch status from _badges | |
uses: actions/checkout@v4 | |
with: | |
path: _badges | |
fetch-depth: 0 | |
- name: Initialize storage branch | |
working-directory: _badges | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
# Switch to the branch if it already exists | |
git switch _badges || true | |
git pull origin _badges || true | |
# Create the branch if it doesn't exist yet | |
git checkout --orphan _badges || true | |
# Ensure that the bare minimum components exist in the branch | |
mkdir -p data | |
touch README.md data/.gitkeep | |
# Copy necessary files and folders to a temporary location | |
mkdir -p /tmp/${{ github.sha }} | |
echo "Copying data to /tmp/${{ github.sha }}" | |
cp -r .git README.md data /tmp/${{ github.sha }} | |
# Remove everything else | |
# Attribution: https://unix.stackexchange.com/a/77313 | |
rm -rf ..?* .[!.]* * | |
# Restore files from the temporary location | |
echo "Copying data from /tmp/${{ github.sha }}" | |
cp -r /tmp/${{ github.sha }}/.git /tmp/${{ github.sha }}/README.md /tmp/${{ github.sha }}/data . | |
rm -rf /tmp/${{ github.sha }} | |
git add --all -f | |
git commit -m "Update storage branch: $(date)" || true | |
shell: bash | |
- name: Push storage branch | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: _badges | |
directory: _badges | |
force: true | |
- name: Get flake8 status | |
id: flake8_status | |
run: | | |
poetry run flake8 src/ && echo "status=passing" >> $GITHUB_OUTPUT || echo "status=failing" >> $GITHUB_OUTPUT | |
- name: Generate the flake8 badge SVG image | |
uses: emibcn/[email protected] | |
id: flake8_badge | |
with: | |
label: 'Flake8' | |
status: "${{ steps.flake8_status.outputs.status }}" | |
color: ${{ steps.flake8_status.outputs.status == 'passing' && 'green' || 'red' }} | |
path: _badges/data/flake8_badge.svg | |
- name: Get complexity check status | |
id: complexity_check_status | |
run: | | |
poetry run flake8 --max-complexity 10 src/ && echo "status=passing" >> $GITHUB_OUTPUT || echo "status=failing" >> $GITHUB_OUTPUT | |
- name: Generate the complexity check badge SVG image | |
uses: emibcn/[email protected] | |
id: complexity_check_badge | |
with: | |
label: 'Cyclomatic complexity' | |
status: "${{ steps.complexity_check_status.outputs.status }}" | |
color: ${{ steps.complexity_check_status.outputs.status == 'passing' && 'green' || 'red' }} | |
path: _badges/data/cyclomatic_complexity.svg | |
- name: Get bandit status | |
id: bandit_status | |
run: | | |
poetry run bandit -c bandit.yaml -r src/ && echo "status=passing" >> $GITHUB_OUTPUT || echo "status=failing" >> $GITHUB_OUTPUT | |
- name: Generate the bandit badge SVG image | |
uses: emibcn/[email protected] | |
id: bandit_badge | |
with: | |
label: 'Bandit' | |
status: "${{ steps.bandit_status.outputs.status }}" | |
color: ${{ steps.bandit_status.outputs.status == 'passing' && 'green' || 'red' }} | |
path: _badges/data/bandit_badge.svg | |
- name: Commit badges | |
working-directory: _badges/data | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git switch _badges || true | |
git pull origin _badges | |
git add "bandit_badge.svg" | |
git add "flake8_badge.svg" | |
git add "cyclomatic_complexity.svg" | |
git commit -m "Add/Update badge: ${{ github.sha }}" || true | |
shell: bash | |
- name: Push badges | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: _badges | |
directory: _badges/data |