Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
[StepSecurity] ci: Harden GitHub Actions (#34)
Browse files Browse the repository at this point in the history
* [StepSecurity] ci: Harden GitHub Actions
Signed-off-by: StepSecurity Bot <[email protected]>

* Write perms for deploying docs

If we had `mkdocs gh-deploy ...` in the run step this would have been `write`.

step-security/secure-repo#1053 and step-security/secure-repo#1066

Co-authored-by: Peter Schutt <[email protected]>
  • Loading branch information
step-security-bot and peterschutt authored Oct 30, 2022
1 parent 3e807ab commit 20cd111
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
67 changes: 51 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ jobs:
name: pylint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{env.PYTHON_LATEST}}
- name: Install Dependencies
Expand All @@ -31,8 +36,13 @@ jobs:
name: mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{env.PYTHON_LATEST}}
- name: Install Dependencies
Expand All @@ -42,8 +52,13 @@ jobs:
name: pyright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{env.PYTHON_LATEST}}
- name: Install Dependencies
Expand All @@ -59,36 +74,46 @@ jobs:
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{matrix.python-version}}
- name: Install Dependencies
run: python -m pip install --upgrade wheel tox tox-gh-actions
- run: python -m tox
- name: Upload Coverage Data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb
with:
name: covdata
path: .coverage.*
coverage:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install --upgrade wheel tox
- name: Download coverage data
uses: actions/download-artifact@v3
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7
with:
name: covdata
- name: Fail if it's <100%.
run: |
python -m tox -e coverage
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb
with:
name: html-report
path: htmlcov
Expand All @@ -103,8 +128,13 @@ jobs:
- coverage
runs-on: Ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{toJSON(needs)}}
release:
Expand All @@ -117,11 +147,16 @@ jobs:
REPOSITORY_USERNAME: __token__
REPOSITORY_PASSWORD: ${{ secrets.PYPI_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
token: ${{ secrets.SEMANTIC_RELEASES_TOKEN }}
- uses: actions/setup-python@v4
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install python-semantic-release
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ on:
push:
tags: ["*"]

permissions: # added using https://github.com/step-security/secure-workflows
contents: write

jobs:
docs:
concurrency:
group: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984
with:
python-version: "3.11"
- run: python -m pip install --upgrade wheel tox
Expand Down

0 comments on commit 20cd111

Please sign in to comment.