Skip to content

Commit

Permalink
fix: docker builds and pushes, condensed workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rilesdun committed Sep 19, 2023
1 parent 8497a60 commit d7e9741
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 104 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/bandit-scan.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/pylint.yml

This file was deleted.

141 changes: 124 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,130 @@ on:
push:
branches:
- main
env:
REGISTRY: docker.io
IMAGE_NAME: rilesdun/peerplays-explorer-api

jobs:

pylint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Set up Python virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Upgrade pip and install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV

- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
scan-and-upload:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Bandit
run: pip install bandit

- name: Create report directory
run: mkdir -p bandit-security-report

- name: Run Bandit and generate report
run: |
bandit -r src/ -f json -o bandit-security-report/bandit-report.json
python json_to_html.py bandit-security-report/bandit-report.json > bandit-security-report/index.html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./bandit-security-report
commit_message: 'Deploy Bandit report to GitHub Pages'

release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit CHANGELOG.md
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "chore: update CHANGELOG.md" || echo "No changes to commit"
git push
dockerhub_publish:
runs-on: ubuntu-latest
steps:
- name: Log into Docker Hub
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0

# Extract metadata (tags, labels)
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Log out from Docker Hub
run: docker logout ${{ env.REGISTRY }}
1 change: 1 addition & 0 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog", // <-- Add this line
"@semantic-release/github"
]
}
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 09-18-2023

### Added
Expand Down
59 changes: 59 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^11.0.0",
"@semantic-release/github": "^9.0.6",
"@semantic-release/release-notes-generator": "^12.0.0",
Expand Down

0 comments on commit d7e9741

Please sign in to comment.