From b71b6b79aa7ed9a28bae2a4d608dfc5477920122 Mon Sep 17 00:00:00 2001 From: Shayan Ghani Date: Sat, 3 May 2025 13:19:53 +0330 Subject: [PATCH] refactor(ci): sperated diffrenet workflow stages for readability --- .github/workflows/cd.yml | 37 +++++++++++++++++++++------------- .github/workflows/ci.yml | 34 +------------------------------ .github/workflows/dev.yml | 10 +++++---- .github/workflows/release.yml | 38 +++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b4ed529..cc09943 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,29 +1,38 @@ -name: CI +name: CD + +## this workflow is for deployment to your actual servers which must be configured +## in the runners section on: - push: - paths-ignore: - - '**.md' - - 'extra/**' - - 'capture/**' - - 'ansible/**' - - 'dashboards/**' - - 'scripts/**' - - '.gitignore' - - 'LICENSE' - branches: - - master + workflow_dispatch: + inputs: + environment: + description: 'Deployment environment' + required: true + default: 'dev' + type: choice + options: + - dev + - production env: ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest jobs: + deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -32,4 +41,4 @@ jobs: - name: deploy from ghcr run: | - IMAGE=${{env.ghcr_repo_addr}} docker compose -f ./container-exporter.yml up -d \ No newline at end of file + IMAGE=${{env.ghcr_repo_addr}} docker compose -f ./container-exporter.yml up -d diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14d2591..2b89a3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,6 @@ name: CI on: - push: - paths-ignore: - - '**.md' - - 'extra/**' - - 'capture/**' - - 'ansible/**' - - 'dashboards/**' - - 'scripts/**' - - '.gitignore' - - 'LICENSE' - branches: - - master pull_request: paths-ignore: - 'extra/**' @@ -101,24 +89,4 @@ jobs: # test: - # ## pytest to be implemented here ... - - release: - if: github.event_name != 'pull_request' && github.ref_name == 'master' - runs-on: ubuntu-latest - needs: healthcheck - steps: - - - name: Bump version and push tag - id: bump - uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - default_bump: patch - - - - name: Create Release - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 - with: - body: ${{ steps.bump.outputs.changelog }} - tag_name: ${{ steps.bump.outputs.new_tag }} \ No newline at end of file + # ## pytest to be implemented here ... \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 10c39cd..1e7c593 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,7 +1,11 @@ -name: CI +name: CI for development branches on: push: + branches-ignore: + - 'main' + - 'master' + paths-ignore: - '**.md' - 'extra/**' @@ -11,9 +15,7 @@ on: - 'scripts/**' - '.gitignore' - 'LICENSE' - branches: - - dev - - ci + pull_request: paths-ignore: - 'extra/**' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2274be4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Github Releaase + +on: + push: + paths-ignore: + - '**.md' + - 'extra/**' + - 'capture/**' + - 'ansible/**' + - 'dashboards/**' + - 'scripts/**' + - '.gitignore' + - 'LICENSE' + branches: + - master + +env: + ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest + +jobs: + release: + if: github.event_name != 'pull_request' && github.ref_name == 'master' + runs-on: ubuntu-latest + steps: + - + name: Bump version and push tag + id: bump + uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + default_bump: patch + + + - name: Create Release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + with: + body: ${{ steps.bump.outputs.changelog }} + tag_name: ${{ steps.bump.outputs.new_tag }} \ No newline at end of file