diff --git a/admin-bypass/action.yaml b/admin-bypass/action.yaml index f7c8a2d7..eb1a0805 100644 --- a/admin-bypass/action.yaml +++ b/admin-bypass/action.yaml @@ -23,35 +23,9 @@ branding: runs: using: "composite" steps: - - name: Set up Python - uses: actions/setup-python@v4 - id: python - with: - python-version: "3.10" - - name: Virtual Environment + - name: Set up Python and pontos id: virtualenv - run: | - echo "path=${{ github.action_path }}/${{ github.action }}-venv" >> $GITHUB_OUTPUT - echo "name=${{ github.action }}-venv" >> $GITHUB_OUTPUT - shell: bash - - name: Cache Virtual Environment - id: cache-virtualenv - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ steps.virtualenv.outputs.name }} - path: ${{ steps.virtualenv.outputs.path }} - - name: Create virtual environment - if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} - run: | - python -m venv ${{ steps.virtualenv.outputs.path }} - shell: bash - - name: Install pontos - run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate - python -m pip install --upgrade pip - python -m pip install --upgrade pontos - wget https://github.com/greenbone/pontos/raw/main/scripts/github/enforce-admins.py -O ~/enforce-admins.py - shell: bash + uses: greenbone/actions/setup-pontos@v2 - name: allow/not allow bypass? run: | if [[ "${{inputs.allow}}" == "true" ]]; @@ -67,7 +41,8 @@ runs: # in case of blubber input let the branch be unlocked! - name: Prepare release and store the version run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate + source ${{ steps.virtualenv.outputs.activate }} + wget https://github.com/greenbone/pontos/raw/main/scripts/github/enforce-admins.py -O ~/enforce-admins.py pontos-github-script ~/enforce-admins.py ${{ inputs.repository }} ${{ inputs.branch }} ${{ env.ALLOW_OPT }} shell: bash env: diff --git a/check-version/action.yaml b/check-version/action.yaml index 484e7d94..2f7a20ad 100644 --- a/check-version/action.yaml +++ b/check-version/action.yaml @@ -18,37 +18,14 @@ runs: using: "composite" steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 - id: python - with: - python-version: ${{ inputs.python-version}} - - name: Virtual Environment + - name: Set up Python ${{ inputs.python-version }} and pontos + uses: actions/setup-pontos@v2 id: virtualenv - run: | - echo "path=${{ github.action_path }}/${{ github.action }}-venv" >> $GITHUB_OUTPUT - echo "name=${{ github.action }}-venv" >> $GITHUB_OUTPUT - shell: bash - - name: Cache Virtual Environment - id: cache-virtualenv - uses: actions/cache@v3 with: - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ steps.virtualenv.outputs.name }} - path: ${{ steps.virtualenv.outputs.path }} - - name: Create virtual environment - if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} - run: | - python -m venv ${{ steps.virtualenv.outputs.path }} - shell: bash - - name: Install pontos - run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate - python -m pip install -U pip - python -m pip install pontos - shell: bash + python-version: ${{ inputs.python-version}} - name: Check version information run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate + source ${{ steps.virtualenv.outputs.activate }} python -m pontos.version verify current shell: bash working-directory: ${{ inputs.working-directory }} diff --git a/lock-branch/action.yaml b/lock-branch/action.yaml index 60d19055..54e11700 100644 --- a/lock-branch/action.yaml +++ b/lock-branch/action.yaml @@ -26,35 +26,9 @@ branding: runs: using: "composite" steps: - - name: Set up Python - uses: actions/setup-python@v4 - id: python - with: - python-version: "3.10" - - name: Virtual Environment + - name: Set up Python and pontos id: virtualenv - run: | - echo "path=${{ github.action_path }}/${{ github.action }}-venv" >> $GITHUB_OUTPUT - echo "name=${{ github.action }}-venv" >> $GITHUB_OUTPUT - shell: bash - - name: Cache Virtual Environment - id: cache-virtualenv - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ steps.virtualenv.outputs.name }} - path: ${{ steps.virtualenv.outputs.path }} - - name: Create virtual environment - if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} - run: | - python -m venv ${{ steps.virtualenv.outputs.path }} - shell: bash - - name: Install pontos - run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate - python -m pip install --upgrade pip - python -m pip install --upgrade pontos - wget https://github.com/greenbone/pontos/raw/main/scripts/github/lock-branch.py -O ~/lock-branch.py - shell: bash + uses: greenbone/actions/setup-pontos@v2 - name: lock/unlock? run: | if [[ "${{inputs.lock}}" == "true" ]]; @@ -70,7 +44,8 @@ runs: # in case of blubber input let the branch be unlocked! - name: Prepare release and store the version run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate + source ${{ steps.virtualenv.outputs.activate }} + wget https://github.com/greenbone/pontos/raw/main/scripts/github/lock-branch.py -O ~/lock-branch.py pontos-github-script ~/lock-branch.py ${{ inputs.repository }} ${{ inputs.branch }} ${{ env.LOCK_OPT }} shell: bash env: diff --git a/setup-pontos/README.md b/setup-pontos/README.md new file mode 100644 index 00000000..bb9c56a0 --- /dev/null +++ b/setup-pontos/README.md @@ -0,0 +1,34 @@ +# Setup Pontos Action + +GitHub Action to setup [pontos](https://github.com/greenbone/pontos) for your +action or workflow. + +```yml +name: Conventional Commits + +on: + pull_request: + +permissions: + pull-requests: write + contents: read + +jobs: + conventional-commits: + name: Report Conventional Commits + runs-on: ubuntu-latest + steps: + - name: Report Conventional Commits + uses: greenbone/actions/conventional-commits@v2 + with: + token: ${{ secrets.SOME_TOKEN }} +``` + +## Action Configuration + +|Input Variable|Description| | +|--------------|-----------|-| +| token | GitHub token to create the pull request comments. | Optional (default is [`github.token`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)) | +| python-version | Python version to use for running the action. | Optional (default is `3.10`) | +| poetry-version | Poetry version to use for running the action. | Optional (default is latest) | +| cache-poetry-installation | Cache poetry and its dependencies. | Optional (default is `true`) | diff --git a/setup-pontos/action.yml b/setup-pontos/action.yml new file mode 100644 index 00000000..c72f82e5 --- /dev/null +++ b/setup-pontos/action.yml @@ -0,0 +1,61 @@ +name: "Setup Pontos Action" +author: "Björn Ricks " +description: "An action to setup python and pontos" +inputs: + cache-key: + description: "Key to use for the cache name." + default: "pontos-venv" + python-version: + description: "Python version that should be installed and used." + default: "3.10" + virtualenv-path: + description: "Path to the created virtual environment" + default: "${{ github.workspace }}/pontos-env" + +outputs: + virtualenv-path: + description: "Path to the created virtual environment" + value: ${{ steps.virtualenv.outputs.path }} + activate: + description: "Path to the activate environment script to source" + value: ${{ steps.virtualenv.outputs.activate }} + +branding: + icon: "package" + color: "green" + +runs: + using: "composite" + steps: + - name: Virtual Environment + id: virtualenv + run: | + echo "path=${{ inputs.virtualenv-path }}" >> $GITHUB_OUTPUT + echo "activate=${{ inputs.virtualenv-path }}/bin/activate" >> $GITHUB_OUTPUT + shell: bash + - name: Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + - name: Cache Virtual Environment + id: cache-virtualenv + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ inputs.cache-key }} + path: ${{ steps.virtualenv.outputs.path }} + - name: Create virtual environment + if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} + run: | + python3 -m venv ${{ steps.virtualenv.outputs.path }} + shell: bash + - name: Install pontos + run: | + source ${{ steps.virtualenv.outputs.activate }} + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade pontos + shell: bash + - name: Print pontos version + run: | + source ${{ steps.virtualenv.outputs.activate }} + pontos --version + shell: bash diff --git a/sign-release-files/action.yml b/sign-release-files/action.yml index 959116cd..00f3c4ac 100644 --- a/sign-release-files/action.yml +++ b/sign-release-files/action.yml @@ -49,34 +49,11 @@ runs: echo "ARGS=${ARGS}" >> $GITHUB_ENV shell: bash - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - id: python - with: - python-version: ${{ inputs.python-version }} - - name: Virtual Environment + - name: Set up Python and pontos + uses: greenbone/actions/setup-pontos@v2 id: virtualenv - run: | - echo "path=${{ github.action_path }}/${{ github.action }}-venv" >> $GITHUB_OUTPUT - echo "name=${{ github.action }}-venv" >> $GITHUB_OUTPUT - shell: bash - - name: Cache Virtual Environment - id: cache-virtualenv - uses: actions/cache@v3 with: - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ steps.virtualenv.outputs.name }} - path: ${{ steps.virtualenv.outputs.path }} - - name: Create virtual environment - if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }} - run: | - python3 -m venv ${{ steps.virtualenv.outputs.path }} - shell: bash - - name: Install pontos - run: | - source ${{ steps.virtualenv.outputs.path }}/bin/activate - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade pontos - shell: bash + python-version: ${{ inputs.python-version }} - name: Import gpg key from secrets run: | echo -e "${{ inputs.gpg-key }}" >> tmp.file @@ -88,7 +65,7 @@ runs: - name: Sign files for released version run: | echo "Signing release files" - source ${{ steps.virtualenv.outputs.path }}/bin/activate + source ${{ steps.virtualenv.outputs.activate }} pontos-release sign ${{ env.ARGS }} --signing-key ${{ inputs.gpg-fingerprint }} --passphrase ${{ inputs.gpg-passphrase }} --versioning-scheme ${{ inputs.versioning-scheme }} shell: bash if: ${{ inputs.sign-release-files == 'true' }} && ${{ inputs.gpg-key }} && ${{ inputs.gpg-fingerprint }} && ${{ inputs.gpg-passphrase }}