diff --git a/.github/workflows/docker-run-test.yml b/.github/workflows/docker-run-test.yml deleted file mode 100644 index 110784a5..00000000 --- a/.github/workflows/docker-run-test.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Docker Run Action Tests - -on: - push: - branches: [ main, 'feature/*' ] - paths: - - 'docker-run/**' - - '.github/workflows/docker-run-test.yml' - pull_request: - branches: [ main, 'feature/*' ] - paths: - - 'docker-run/**' - - '.github/workflows/docker-run-test.yml' - workflow_dispatch: - -jobs: - smoke-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run docker action and set output for testing - uses: ./docker-run - id: run-docker - with: - image: docker:20.10.3 - run: | - echo "::set-output name=docker-version::$(echo $DOCKER_VERSION)" - - - name: Test the output - uses: actions/github-script@v6 - with: - script: | - const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}'; - if (dockerVersion !== '20.10.3') { - core.setFailed(`Smoke Test Failed`); - } - - volume-mount-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Create File to be mounted - run: echo "some text" > someFile - - name: Run docker action with mounted workspace - uses: ./docker-run - id: run-docker - with: - image: docker - options: -v ${{ github.workspace }}:/work - run: | - echo "::set-output name=file-contents::`cat /work/someFile`" - - name: Check if file contents match - uses: actions/github-script@v6 - with: - script: | - const fileContents = '${{ steps.run-docker.outputs.file-contents }}'; - if (fileContents !== 'some text') { - core.setFailed(`Unable to mount workspace volume`); - } - - container-network-test: - runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: test - POSTGRES_USER: test - POSTGRES_DB: test - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10 - steps: - - uses: actions/checkout@v3 - - name: Run docker action and test network connection - uses: ./docker-run - with: - image: postgres - run: > - pg_isready -d test -U test -h postgres -p ${{ job.services.postgres.ports[5432] }} - options: > - -e PGPASSWORD=test diff --git a/docker-run/Dockerfile b/docker-run/Dockerfile deleted file mode 100644 index 1b94fb81..00000000 --- a/docker-run/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM docker:20.10 - -RUN apk add bash - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-run/LICENSE b/docker-run/LICENSE deleted file mode 100644 index ffa58995..00000000 --- a/docker-run/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2020 Abdud Dayan Adeeb -Copyright (c) 2021 Greenbone AG - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/docker-run/README.md b/docker-run/README.md deleted file mode 100644 index b6dc6457..00000000 --- a/docker-run/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# Docker Run Action - -- run a specific step in docker. -- run an image built by a previous step. -- See https://github.com/greenbone/actions/blob/main/docker-run/action.yml for all the available inputs. - -## Examples - -#### Typical Use Case - -```yaml -- name: Checkout - uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume -- uses: greenbone/actions/docker-run@v1 - env: - ABC: 123 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - registry: gcr.io - image: private-image:latest - run: | - echo "Running Script" - /work/run-script -``` - -#### run a privately-owned image - -```yaml -- uses: greenbone/actions/docker-run@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - registry: gcr.io - image: test-image:latest - run: echo "hello world" -``` - -#### run an image built by a previous step - -```yaml -- uses: docker/build-push-action@v2 - with: - tags: test-image:latest - push: false -- uses: greenbone/actions/docker-run@v1 - with: - image: test-image:latest - run: echo "hello world" -``` - -#### use a specific shell (default: sh). - -*Note: The shell must be installed in the container* - -```yaml -- uses: greenbone/actions/docker-run@v1 - with: - image: docker:latest - shell: bash - run: | - echo "first line" - echo "second line" -``` - -#### Capture Output from a Docker Container - -You can capture output from the container, using -the `::set-output` [workflow command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions) -in GitHub Actions. Steps that execute following this step can access the output using -the `${{ steps.<step_id>.outputs.<output_name> }}` syntax. For more information, see -the [Contexts documentation](https://docs.github.com/en/actions/learn-github-actions/contexts) for GitHub Actions. - -```yaml -- uses: greenbone/actions/docker-run@v1 - id: container_test - with: - image: mcr.microsoft.com/powershell - run: | - pwsh -EncodedCommand JABJAG4AcwB0AGEAbABsAGUAZABNAG8AZAB1AGwAZQBzACAAPQAgACgARwBlAHQALQBNAG8AZAB1AGwAZQAgAC0ATABpAHMAdABBAHYAYQBpAGwAYQBiAGwAZQApAC4ATgBhAG0AZQAgAC0AagBvAGkAbgAgACcALAAnAAoAJwA6ADoAcwBlAHQALQBvAHUAdABwAHUAdAAgAG4AYQBtAGUAPQBjAG8AbgB0AGEAaQBuAGUAcgBfAG8AdQB0AHAAdQB0ADoAOgB7ADAAfQAnACAALQBmACAAJABJAG4AcwB0AGEAbABsAGUAZABNAG8AZAB1AGwAZQBzAA== -- run: - echo "Installed PowerShell modules are: ${{ steps.container_test.outputs.container_output }}" -``` - -# Fork - -This is a Fork of [addnab/docker-run-action](https://github.com/addnab/docker-run-action) with some modifications diff --git a/docker-run/action.yml b/docker-run/action.yml deleted file mode 100644 index 5ed3b157..00000000 --- a/docker-run/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -# action.yml -name: 'Docker Run Action' -description: 'Run a command in a new container' -inputs: - image: - description: 'Image' - required: true - options: - description: 'Options' - required: false - workdir: - description: 'Workdir for the container' - required: false - default: /github/workspace/${{ github.event.repository.name }} - run: - description: 'Run command in container' - required: false - shell: - description: 'Use a specific shell' - required: false - default: sh - registry: - description: 'Registry' - required: false - username: - description: 'Username' - required: false - password: - description: 'Password' - required: false - docker_network: - description: 'Docker Network ID' - default: ${{ job.container.network }} - required: false -outputs: - container_output: - description: 'The output from the container execution' -runs: - using: 'docker' - image: 'Dockerfile' diff --git a/docker-run/entrypoint.sh b/docker-run/entrypoint.sh deleted file mode 100755 index d7557b02..00000000 --- a/docker-run/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -echo "" >docker-run-action.env -for env_var in $(env | cut -f1 -d"="); do - eval var=\$$env_var - if [[ -z $var ]] || [[ "$env_var" == "PATH" ]] || [[ "$env_var" == "DOCKER_VERSION" ]] || - [[ "$env_var" == "_" ]] || [[ "$env_var" == "SHLVL" ]] || [[ "$env_var" == "PWD" ]]; then - continue - fi - echo "${env_var}=${var@Q}" >>docker-run-action.env -done - -if [[ -n $INPUT_USERNAME ]]; then - echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin -fi - -if [[ -n $INPUT_DOCKER_NETWORK ]]; then - INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" -fi - -exec docker run --env-file docker-run-action.env --workdir "$INPUT_WORKDIR" -v "/var/run/docker.sock:/var/run/docker.sock" -v "$RUNNER_WORKSPACE:/github/workspace" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}" diff --git a/github-release/README.md b/github-release/README.md deleted file mode 100644 index 26214f18..00000000 --- a/github-release/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Github release - -- Create github release with tag - -#### Use Case - -```yaml -jobs: - github-release: - name: Create a github release - runs-on: - - self-hosted - - self-hosted-generic - steps: - - uses: greenbone/actions/github-release@v2 - with: - release-name: - tag-name: - create-tag: true/false default false - draft: true/false default false - prerelease: true/false default false - github-user: - github-user-mail: - github-user-token: -``` - diff --git a/github-release/action.yml b/github-release/action.yml deleted file mode 100644 index 7fdcdd82..00000000 --- a/github-release/action.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: "Create github release" -description: "Create a github release" -inputs: - github-user: - description: "Github user name." - required: true - github-user-mail: - description: "Mail address for the given github user." - required: true - github-user-token: - description: "Token with write rights required to create the release." - required: true - tag-name: - description: "Tag name to use with release." - required: true - create-tag: - description: "Create the Tag." - required: false - default: 'false' - release-name: - description: "Release name." - required: true - draft: - description: "Create a draft release." - required: false - default: 'false' - prerelease: - description: "Create a prerelease." - required: false - default: 'false' - -branding: - icon: "package" - color: "green" - -runs: - using: "composite" - steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Install Pontos - shell: bash - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade pontos - - name: Create Tag - if: inputs.create-tag == 'true' - shell: bash - env: - GITHUB_USER: ${{ inputs.github-user }} - GITHUB_TOKEN: ${{ inputs.github-user-token }} - run: | - pontos-github tag create "$GITHUB_REPOSITORY" "${{ inputs.tag-name }}" \ - "${{ inputs.github-user }}" '' "$GITHUB_SHA" "${{ inputs.github-user-mail }}" - - name: Create Release - shell: bash - env: - GITHUB_USER: ${{ inputs.github-user }} - GITHUB_TOKEN: ${{ inputs.github-user-token }} - run: | - flags='' - if [ "${{ inputs.prerelease }}" == 'true' ]; then - flags+=' --prerelease' - fi - if [ "${{ inputs.draft }}" == 'true' ]; then - flags+=' --draft' - fi - - pontos-github release create "$GITHUB_REPOSITORY" \ - "${{ inputs.tag-name }}" "${{ inputs.release-name }}" \ - $flags diff --git a/reference-version/action.yaml b/reference-version/action.yaml deleted file mode 100644 index ab41e3a4..00000000 --- a/reference-version/action.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: "Find a version by referenced branch or tag" -author: "Björn Ricks <bjoern.ricks@greenbone.net>" -description: "An action to get the target branch or current tag name and use it as a version" -branding: - icon: "package" - color: "green" - -inputs: - strip-tag-prefix: - description: "The tag prefix to strip i.e v1.2.3 -> 1.2.3 (default 'v')" - default: "v" - required: false - -runs: - using: "composite" - steps: - - run: | - if [ -n "$GITHUB_BASE_REF" ]; - then - echo "REF=${GITHUB_BASE_REF}" >> $GITHUB_ENV; - echo "VERSION=${GITHUB_BASE_REF}" >> $GITHUB_ENV; - else - echo "REF=${GITHUB_REF}" >> $GITHUB_ENV; - echo "VERSION=${GITHUB_REF##refs/*/}" >> $GITHUB_ENV; - fi; - echo "::warning title=reference-version is deprecated:: The reference-version action is deprecated. Please use `github.ref_name` instead. See https://docs.github.com/en/actions/learn-github-actions/contexts#github-context for more details." - shell: bash - name: Set version in environment - - run: | - echo "${REF}" - if [[ "${REF}" == "refs/tags/"* ]]; - then echo "VERSION=${VERSION##${{ inputs.strip-tag-prefix}}}" >> $GITHUB_ENV; - fi; - shell: bash - name: Remove the tag prefix