Skip to content

Pin GitHub Actions

Pin GitHub Actions #96

Workflow file for this run

---
name: Release new version on PyPI and DockerHub
on:
workflow_dispatch:
pull_request:
types:
- closed
jobs:
create-github-release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Extract version from prismacloud/cli/version.py
run: |
version=$(grep 'version = ' prismacloud/cli/version.py | sed -E "s/version = \"([^\"]+)\"/\1/")
echo "PRISMA_CLOUD_CLI_VERSION=$version" >> $GITHUB_ENV
- name: Create GitHub Release
run: |
gh release create ${{ env.PRISMA_CLOUD_CLI_VERSION }} --generate-notes --latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pypireleaser:
runs-on: ubuntu-latest
permissions: write-all
needs:
- create-github-release
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install pylint
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
- name: Install flake8
run: |
pip install flake8
- name: Analysing the code with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# execute overall flake8 scan
flake8 . --count --statistics
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
publish-dockerhub:
permissions: write-all
runs-on: ubuntu-latest
needs:
- pypireleaser
- create-github-release
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@219613003b08f4d049f34cb56c92e84345e1bb3f # v5
with:
name: simonpanw/prismacloud-cli
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tags: "latest,${{ env.PRISMA_CLOUD_CLI_VERSION }}"
- name: Update Docker Hub README
uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864 # v3.4.2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: simonpanw/prismacloud-cli
short-description: ${{ github.event.repository.description }}
readme-filepath: ./README.md