From 86d60cc0fc0548cedbd981a010862b50ba0995e4 Mon Sep 17 00:00:00 2001 From: Henrik Stranneheim Date: Thu, 7 Mar 2024 08:07:56 +0100 Subject: [PATCH] Clean actions (#82) ### Changed - Harmonize actions --- .../workflows/build_dockerfile_on_push.yml | 37 +++++++++ ...ci.yml => build_dockerfile_on_release.yml} | 0 .github/workflows/bumpversion.yml | 18 +++++ .github/workflows/merge_master_ci.yml | 79 ------------------- .github/workflows/pull_request_ci.yml | 78 ------------------ 5 files changed, 55 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/build_dockerfile_on_push.yml rename .github/workflows/{release_ci.yml => build_dockerfile_on_release.yml} (100%) create mode 100644 .github/workflows/bumpversion.yml diff --git a/.github/workflows/build_dockerfile_on_push.yml b/.github/workflows/build_dockerfile_on_push.yml new file mode 100644 index 0000000..38d91fc --- /dev/null +++ b/.github/workflows/build_dockerfile_on_push.yml @@ -0,0 +1,37 @@ +--- + +name: Build and publish docker image on push + +on: [push] + +jobs: + docker-image-push: + runs-on: ubuntu-latest + name: Create staging docker image + steps: + - name: Check out git repository + uses: actions/checkout@v4.1.1 + + - name: Extract branch name and remove illegal chars + id: get_branch_name + shell: bash + run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")" + + - name: Login to Docker Hub + uses: docker/login-action@v3.0.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.1.0 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v5.1.0 + with: + context: ./ + file: ./Dockerfile + push: true + tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" diff --git a/.github/workflows/release_ci.yml b/.github/workflows/build_dockerfile_on_release.yml similarity index 100% rename from .github/workflows/release_ci.yml rename to .github/workflows/build_dockerfile_on_release.yml diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml new file mode 100644 index 0000000..5662933 --- /dev/null +++ b/.github/workflows/bumpversion.yml @@ -0,0 +1,18 @@ +name: "Bump2version-CI" +on: + push: + branches: + - "master" + - "main" +jobs: + bump-version: + runs-on: ubuntu-latest + name: Bump version and push tags to master + steps: + - name: Bump version + uses: Clinical-Genomics/bump2version-ci@v3 + env: + BUMPVERSION_TOKEN: ${{ secrets.BUMPVERSION_TOKEN }} + BUMPVERSION_AUTHOR: ${{ secrets.BUMPVERSION_AUTHOR }} + BUMPVERSION_EMAIL: ${{ secrets.BUMPVERSION_EMAIL }} + GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/.github/workflows/merge_master_ci.yml b/.github/workflows/merge_master_ci.yml index bfdc806..e69de29 100644 --- a/.github/workflows/merge_master_ci.yml +++ b/.github/workflows/merge_master_ci.yml @@ -1,79 +0,0 @@ -name: 'Merge-master-CI' -on: - push: - branches: - - 'master' - - 'main' - -jobs: - bump-version: - runs-on: ubuntu-latest - name: Bump version and push tags to master - steps: - - name: Bump version - uses: Clinical-Genomics/bump2version-ci@v3 - env: - BUMPVERSION_TOKEN: ${{ secrets.BUMPVERSION_TOKEN }} - BUMPVERSION_AUTHOR: ${{ secrets.BUMPVERSION_AUTHOR }} - BUMPVERSION_EMAIL: ${{ secrets.BUMPVERSION_EMAIL }} - GITHUB_REPOSITORY: ${{ github.repository }} - - docker-image-push: - runs-on: ubuntu-latest - name: Create staging image - steps: - - name: Check out git repository - uses: actions/checkout@v4.1.1 - - - name: Extract branch name and remove illegal chars - id: get_branch_name - shell: bash - run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")" - - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.1.0 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5.1.0 - with: - context: ./ - file: ./Dockerfile - push: true - tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" - - tests-coverage: - runs-on: ubuntu-latest - name: Test and coveralls - steps: - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: "3.10" - - - name: Check out genotype-api - uses: actions/checkout@v4.1.1 - with: - repository: "Clinical-Genomics/genotype-api" - - - name: Install genotype-api dependencies - run: | - pip install -r requirements.txt -r requirements-dev.txt . - - name: Install coveralls dependencies - run: | - pip install pytest-cov coveralls - - name: Test with pytest & Coveralls - run: | - pytest --cov=genotype-api/ - coveralls - env: - GITHUB: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} diff --git a/.github/workflows/pull_request_ci.yml b/.github/workflows/pull_request_ci.yml index 3aad712..e69de29 100644 --- a/.github/workflows/pull_request_ci.yml +++ b/.github/workflows/pull_request_ci.yml @@ -1,78 +0,0 @@ ---- - -name: Pull Request Actions - -on: [push] - -jobs: - black-lint: - runs-on: ubuntu-latest - name: Black - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-python@v5.0.0 - - uses: psf/black@stable - with: - black_args: ". --check --line-length 100" - - docker-image-push: - runs-on: ubuntu-latest - name: Create staging docker image - steps: - - name: Check out git repository - uses: actions/checkout@v4.1.1 - - - name: Extract branch name and remove illegal chars - id: get_branch_name - shell: bash - run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")" - - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.1.0 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5.1.0 - with: - context: ./ - file: ./Dockerfile - push: true - tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" - - tests-coverage: - runs-on: ubuntu-latest - name: Test and coveralls - steps: - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: "3.10" - - - name: Check out genotype-api - uses: actions/checkout@v4.1.1 - with: - repository: "Clinical-Genomics/genotype-api" - - - name: Install genotype-api dependencies - run: | - pip install -r requirements.txt -r requirements-dev.txt . - - - name: Install coveralls dependencies - run: | - pip install pytest-cov coveralls - - - name: Test with pytest & Coveralls - run: | - pytest --cov=genotype_api/ - coveralls - env: - GITHUB: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}