From 5871af4a4f5089e17f48efa50bf0970c263dbef4 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:05:32 +0100 Subject: [PATCH 01/18] ENH: Add version and compose check to workflow --- .github/workflows/cloud_chatops.yaml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 4140ad5..9be548d 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -51,6 +51,38 @@ jobs: token: ${{secrets.CODECOV_TOKEN}} files: cloud-chatops/coverage.xml + + check_version_update: + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v4 + with: + ref: 'main' + path: 'main' + + - name: Checkout current working branch + uses: actions/checkout@v4 + with: + path: 'branch' + + - name: Compare versions + if: ${{ github.ref != 'refs/heads/main' }} + uses: khalford/check-version-action@main + with: + app_version_path: "cloud-chatops/version.txt" + docker_compose_path: "cloud-chatops/docker-compose.yaml" + + - name: Log App Success + if: ${{ env.app_updated == 'true' }} + run: | + echo "App version has been updated correctly!" + + - name: Log Compose Success + if: ${{ env.compose_updated == 'true' }} + run: | + echo "Compose version has been updated correctly!" + push_dev_image_harbor: runs-on: ubuntu-latest needs: test_and_lint From 3279c283413f11400b23018a0c7a7637682279c5 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:21:03 +0100 Subject: [PATCH 02/18] BUG: branch is master not main --- .github/workflows/cloud_chatops.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 9be548d..c880572 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -55,10 +55,10 @@ jobs: check_version_update: runs-on: ubuntu-latest steps: - - name: Checkout main + - name: Checkout master uses: actions/checkout@v4 with: - ref: 'main' + ref: 'master' path: 'main' - name: Checkout current working branch @@ -67,7 +67,7 @@ jobs: path: 'branch' - name: Compare versions - if: ${{ github.ref != 'refs/heads/main' }} + if: ${{ github.ref != 'refs/heads/master' }} uses: khalford/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" From 264465b9892866cb63d67c247cb6288521a40143 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:26:34 +0100 Subject: [PATCH 03/18] MAINT: Track dev not main to follow changes --- .github/workflows/cloud_chatops.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index c880572..927a0d6 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -68,7 +68,7 @@ jobs: - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@main + uses: khalford/check-version-action@dev with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml" From d331486c99fd0d92361e9ae1ada6cbd90a5303bb Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:36:38 +0100 Subject: [PATCH 04/18] BUG: Try absolute paths --- .github/workflows/cloud_chatops.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 927a0d6..9d68c90 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -59,12 +59,12 @@ jobs: uses: actions/checkout@v4 with: ref: 'master' - path: 'main' + path: '/app/main' - name: Checkout current working branch uses: actions/checkout@v4 with: - path: 'branch' + path: '/app/branch' - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} From b0f913e8779fd9313d7cf40156f73e4898ed3a66 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:39:42 +0100 Subject: [PATCH 05/18] revert changes --- .github/workflows/cloud_chatops.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 9d68c90..c880572 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -59,16 +59,16 @@ jobs: uses: actions/checkout@v4 with: ref: 'master' - path: '/app/main' + path: 'main' - name: Checkout current working branch uses: actions/checkout@v4 with: - path: '/app/branch' + path: 'branch' - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@dev + uses: khalford/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml" From 39366961d0d6f1114f31fd27106cd53a79a037a6 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 16:02:46 +0100 Subject: [PATCH 06/18] ENH: Tidy workflow --- .github/workflows/cloud_chatops.yaml | 69 ++++++++++++---------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index c880572..2a805dd 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -51,6 +51,35 @@ jobs: token: ${{secrets.CODECOV_TOKEN}} files: cloud-chatops/coverage.xml + push_dev_image_harbor: + runs-on: ubuntu-latest + needs: test_and_lint + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Harbor + uses: docker/login-action@v3 + with: + registry: harbor.stfc.ac.uk + username: ${{ secrets.STAGING_HARBOR_USERNAME }} + password: ${{ secrets.STAGING_HARBOR_TOKEN }} + + - name: Set commit SHA for later + id: commit_sha + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build and push to staging project + uses: docker/build-push-action@v6 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + context: "{{defaultContext}}:cloud-chatops" + tags: "harbor.stfc.ac.uk/stfc-cloud-staging/cloud-chatops:${{ steps.commit_sha.outputs.sha_short }}" + check_version_update: runs-on: ubuntu-latest @@ -83,38 +112,9 @@ jobs: run: | echo "Compose version has been updated correctly!" - push_dev_image_harbor: - runs-on: ubuntu-latest - needs: test_and_lint - steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Harbor - uses: docker/login-action@v3 - with: - registry: harbor.stfc.ac.uk - username: ${{ secrets.STAGING_HARBOR_USERNAME }} - password: ${{ secrets.STAGING_HARBOR_TOKEN }} - - - name: Set commit SHA for later - id: commit_sha - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - - name: Build and push to staging project - uses: docker/build-push-action@v6 - with: - cache-from: type=gha - cache-to: type=gha,mode=max - push: true - context: "{{defaultContext}}:cloud-chatops" - tags: "harbor.stfc.ac.uk/stfc-cloud-staging/cloud-chatops:${{ steps.commit_sha.outputs.sha_short }}" - push_prod_image_harbor: runs-on: ubuntu-latest - needs: test_and_lint + needs: [test_and_lint, check_version_update] if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v4 @@ -133,17 +133,8 @@ jobs: id: release_tag run: echo "version=$(cat cloud-chatops/version.txt)" >> $GITHUB_OUTPUT - - name: Check if release file has updated - uses: dorny/paths-filter@v2 - id: release_updated - with: - filters: | - version: - - 'cloud-chatops/version.txt' - - name: Build and push on version change uses: docker/build-push-action@v6 - if: steps.release_updated.outputs.version == 'true' with: cache-from: type=gha cache-to: type=gha,mode=max From 7caa8bfd8565f9bc678c03791d35ea158482b077 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 16:05:32 +0100 Subject: [PATCH 07/18] MAINT: Bump version --- cloud-chatops/docker-compose.yaml | 2 +- cloud-chatops/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-chatops/docker-compose.yaml b/cloud-chatops/docker-compose.yaml index 6d4223f..5c65f63 100644 --- a/cloud-chatops/docker-compose.yaml +++ b/cloud-chatops/docker-compose.yaml @@ -1,6 +1,6 @@ services: cloud_chatops: - image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops + image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops:1.0.5 volumes: - $HOME/cloud_chatops_secrets/:/usr/src/app/cloud_chatops_secrets/ watchtower: diff --git a/cloud-chatops/version.txt b/cloud-chatops/version.txt index ee90284..90a27f9 100644 --- a/cloud-chatops/version.txt +++ b/cloud-chatops/version.txt @@ -1 +1 @@ -1.0.4 +1.0.5 From 3abd705d59ba89542849fdf359a0cfc63e96e91d Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 23 Oct 2024 11:44:51 +0100 Subject: [PATCH 08/18] MAINT: Change to STFC repo --- .github/workflows/cloud_chatops.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 2a805dd..a8efd8f 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -97,7 +97,7 @@ jobs: - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@main + uses: stfc/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml" From 6f823d7136ee29ac393df4b9846903fae77b56b1 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 23 Oct 2024 13:44:12 +0100 Subject: [PATCH 09/18] MAINT: Bump versions This also includes updating the compose file from a previous update that was forgotten --- cloud-chatops/docker-compose.yaml | 2 +- cloud-chatops/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-chatops/docker-compose.yaml b/cloud-chatops/docker-compose.yaml index dc54b17..6709fad 100644 --- a/cloud-chatops/docker-compose.yaml +++ b/cloud-chatops/docker-compose.yaml @@ -1,5 +1,5 @@ services: cloud_chatops: - image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops:1.1.0 + image: harbor.stfc.ac.uk/stfc-cloud/cloud-chatops:2.0.2 volumes: - $HOME/cloud_chatops_secrets/:/usr/src/app/cloud_chatops_secrets/ diff --git a/cloud-chatops/version.txt b/cloud-chatops/version.txt index 38f77a6..e9307ca 100644 --- a/cloud-chatops/version.txt +++ b/cloud-chatops/version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 From 4c1e2de6b91a220107677d14ff5f188accd9bcae Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 23 Oct 2024 13:44:44 +0100 Subject: [PATCH 10/18] DOC: Update template config The template config does not need comments as the config is explained in the readme --- cloud-chatops/template_config.yml | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/cloud-chatops/template_config.yml b/cloud-chatops/template_config.yml index 06d9637..ac62760 100644 --- a/cloud-chatops/template_config.yml +++ b/cloud-chatops/template_config.yml @@ -1,26 +1,13 @@ --- -maintainer: AB12CD34 # Slack Member ID of the application maintainer +maintainer: -user-map: # Dictionary of GitHub username to Slack Member ID - my_github_username: AB12CD34 - other_github_username: EF56GH78 +user-map: + : -repos: # Dictionary of owners and repositories - organisation1: - - repo1 # E.g. github.com/organisation1/repo1 - - repo2 - - repo3 - organisation2: - - repo1 # E.g. github.com/organisation2/repo1 - - repo2 - - repo3 +repos: + : + - -defaults: # Default values for application variables - # Default author will be assigned to pull requests where the PR author is not in the above user map. - # Usually team lead or senior staff member. - author: WX67YZ89 # Slack member ID - - # Default channel is where the pull requests will be posted. - # It's recommended to set this as a "maintenance" / "dev" channel in case the application goes awry. - # The actual channel messages are sent to can be specified in the code. - channel: CH12NN34 # Slack channel ID +defaults: + author: + channel: From 77acbd587ecd26fdf2e594cfa9662171f5ea8d87 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 23 Oct 2024 13:45:13 +0100 Subject: [PATCH 11/18] DOC: Updates to readme --- cloud-chatops/README.md | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/cloud-chatops/README.md b/cloud-chatops/README.md index 9f48416..1c793b1 100644 --- a/cloud-chatops/README.md +++ b/cloud-chatops/README.md @@ -25,7 +25,7 @@ These slash commands can be run in any channel the application has access to.
-Events are defined in the `schedule_jobs` function:
+Events are defined in the `main.py/schedule_jobs` function:
- `run_global_reminder()`: Sends a message to the pull request channel with every open pull request across the repositories in a thread. - `run_personal_reminder()`: Sends a message to each user directly with a thread of their open pull requests. @@ -44,8 +44,18 @@ The latest version can be found in [version.txt](version.txt)
docker run -v $HOME/cloud_chatops_secrets/:/usr/src/app/cloud_chatops_secrets/ cloud_chatops -d ``` - ```shell - # Pull from harbor and run + # First log in to harbor + docker login -u harbor.stfc.ac.uk + + # Then either: + + # Run container directly, specifying a version docker run -v $HOME/cloud_chatops_secrets/:/usr/src/app/cloud_chatops_secrets/ harbor.stfc.ac.uk/stfc-cloud/cloud-chatops: -d + # + # or + # + # Use Docker Compose in cloud-chatops folder, which will always contain latest image version + docker compose up -d ``` #### Running from source: @@ -53,22 +63,22 @@ You can run the code from [main.py](src/main.py).
It's always recommended to create a [virtual environment](https://docs.python.org/3/library/venv.html) for the application to run before installing dependencies. - ```shell + # Install Venv module + python3 -m venv my_venv + # Activate venv source my_venv/bin/activate + # Install requirements pip3 install -r requirements.txt + # Run app python3 cloud-chatops/src/main.py prod ``` - - - - - ### Requirements: Two files required for the deployment of this application: `config.yml` and `secrets.json`.
These should be stored in `$HOME/cloud_chatops_secrets` on the host system.
-#### Config +#### Config: The application configuration is stored in [config.yml](template_config.yml). This includes information such as username mapping, repositories to check and default values.
Slack Channel and Member IDs can be found in Slack by:
@@ -105,13 +115,7 @@ defaults: # Default values for application variables # The actual channel messages are sent to can be specified in the code. channel: CH12NN34 # Slack channel ID ``` -#### Secrets - -The application needs secrets for Slack and GitHub.
-TODO: How to run your own Slack application or find on slack marketplace.
-A GitHub Personal Access Token is needed to bypass rate limiting and allows access to private repositories.
-Documentation on how to create a GitHub personal access token can be found -[here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
+#### Secrets: The `secrets.json` file should look like the below and there is a template [here](template_secrets.json) ```json { @@ -120,3 +124,10 @@ The `secrets.json` file should look like the below and there is a template [here "GITHUB_TOKEN": "" } ``` +Slack:
+- TODO: How to create your own Slack application.
+ +GitHub:
+- A GitHub Personal Access Token is needed to bypass rate limiting and allows access to private repositories.
+- Documentation on how to create a GitHub personal access token can be found +[here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
From 9fe8b43e23d81f4dc52419a04e1509a6269fec97 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:05:32 +0100 Subject: [PATCH 12/18] ENH: Add version and compose check to workflow --- .github/workflows/cloud_chatops.yaml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 4140ad5..9be548d 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -51,6 +51,38 @@ jobs: token: ${{secrets.CODECOV_TOKEN}} files: cloud-chatops/coverage.xml + + check_version_update: + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v4 + with: + ref: 'main' + path: 'main' + + - name: Checkout current working branch + uses: actions/checkout@v4 + with: + path: 'branch' + + - name: Compare versions + if: ${{ github.ref != 'refs/heads/main' }} + uses: khalford/check-version-action@main + with: + app_version_path: "cloud-chatops/version.txt" + docker_compose_path: "cloud-chatops/docker-compose.yaml" + + - name: Log App Success + if: ${{ env.app_updated == 'true' }} + run: | + echo "App version has been updated correctly!" + + - name: Log Compose Success + if: ${{ env.compose_updated == 'true' }} + run: | + echo "Compose version has been updated correctly!" + push_dev_image_harbor: runs-on: ubuntu-latest needs: test_and_lint From eb99ac3f1838ded235f8f62461ddf1a7cf18d2e1 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:21:03 +0100 Subject: [PATCH 13/18] BUG: branch is master not main --- .github/workflows/cloud_chatops.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 9be548d..c880572 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -55,10 +55,10 @@ jobs: check_version_update: runs-on: ubuntu-latest steps: - - name: Checkout main + - name: Checkout master uses: actions/checkout@v4 with: - ref: 'main' + ref: 'master' path: 'main' - name: Checkout current working branch @@ -67,7 +67,7 @@ jobs: path: 'branch' - name: Compare versions - if: ${{ github.ref != 'refs/heads/main' }} + if: ${{ github.ref != 'refs/heads/master' }} uses: khalford/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" From 1818c4bf255f427ef7f75db81d335b14dd31fd09 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:26:34 +0100 Subject: [PATCH 14/18] MAINT: Track dev not main to follow changes --- .github/workflows/cloud_chatops.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index c880572..927a0d6 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -68,7 +68,7 @@ jobs: - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@main + uses: khalford/check-version-action@dev with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml" From b5abe8d00b23741db9e36470aec63787f7eebbb5 Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:36:38 +0100 Subject: [PATCH 15/18] BUG: Try absolute paths --- .github/workflows/cloud_chatops.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 927a0d6..9d68c90 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -59,12 +59,12 @@ jobs: uses: actions/checkout@v4 with: ref: 'master' - path: 'main' + path: '/app/main' - name: Checkout current working branch uses: actions/checkout@v4 with: - path: 'branch' + path: '/app/branch' - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} From 0060c48f8be654cd0fa816db9c1e8214bea0b06c Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 15:39:42 +0100 Subject: [PATCH 16/18] revert changes --- .github/workflows/cloud_chatops.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 9d68c90..c880572 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -59,16 +59,16 @@ jobs: uses: actions/checkout@v4 with: ref: 'master' - path: '/app/main' + path: 'main' - name: Checkout current working branch uses: actions/checkout@v4 with: - path: '/app/branch' + path: 'branch' - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@dev + uses: khalford/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml" From 5d89152b831ea7db2962bed365fb2518c4d2e34d Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 2 Oct 2024 16:02:46 +0100 Subject: [PATCH 17/18] ENH: Tidy workflow --- .github/workflows/cloud_chatops.yaml | 69 ++++++++++++---------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index c880572..2a805dd 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -51,6 +51,35 @@ jobs: token: ${{secrets.CODECOV_TOKEN}} files: cloud-chatops/coverage.xml + push_dev_image_harbor: + runs-on: ubuntu-latest + needs: test_and_lint + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Harbor + uses: docker/login-action@v3 + with: + registry: harbor.stfc.ac.uk + username: ${{ secrets.STAGING_HARBOR_USERNAME }} + password: ${{ secrets.STAGING_HARBOR_TOKEN }} + + - name: Set commit SHA for later + id: commit_sha + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build and push to staging project + uses: docker/build-push-action@v6 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + context: "{{defaultContext}}:cloud-chatops" + tags: "harbor.stfc.ac.uk/stfc-cloud-staging/cloud-chatops:${{ steps.commit_sha.outputs.sha_short }}" + check_version_update: runs-on: ubuntu-latest @@ -83,38 +112,9 @@ jobs: run: | echo "Compose version has been updated correctly!" - push_dev_image_harbor: - runs-on: ubuntu-latest - needs: test_and_lint - steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Harbor - uses: docker/login-action@v3 - with: - registry: harbor.stfc.ac.uk - username: ${{ secrets.STAGING_HARBOR_USERNAME }} - password: ${{ secrets.STAGING_HARBOR_TOKEN }} - - - name: Set commit SHA for later - id: commit_sha - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - - name: Build and push to staging project - uses: docker/build-push-action@v6 - with: - cache-from: type=gha - cache-to: type=gha,mode=max - push: true - context: "{{defaultContext}}:cloud-chatops" - tags: "harbor.stfc.ac.uk/stfc-cloud-staging/cloud-chatops:${{ steps.commit_sha.outputs.sha_short }}" - push_prod_image_harbor: runs-on: ubuntu-latest - needs: test_and_lint + needs: [test_and_lint, check_version_update] if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v4 @@ -133,17 +133,8 @@ jobs: id: release_tag run: echo "version=$(cat cloud-chatops/version.txt)" >> $GITHUB_OUTPUT - - name: Check if release file has updated - uses: dorny/paths-filter@v2 - id: release_updated - with: - filters: | - version: - - 'cloud-chatops/version.txt' - - name: Build and push on version change uses: docker/build-push-action@v6 - if: steps.release_updated.outputs.version == 'true' with: cache-from: type=gha cache-to: type=gha,mode=max From 322d2fb56741a4811c391545b77be744ca0e7b1a Mon Sep 17 00:00:00 2001 From: Kalibh Halford Date: Wed, 23 Oct 2024 11:44:51 +0100 Subject: [PATCH 18/18] MAINT: Change to STFC repo --- .github/workflows/cloud_chatops.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cloud_chatops.yaml b/.github/workflows/cloud_chatops.yaml index 2a805dd..a8efd8f 100644 --- a/.github/workflows/cloud_chatops.yaml +++ b/.github/workflows/cloud_chatops.yaml @@ -97,7 +97,7 @@ jobs: - name: Compare versions if: ${{ github.ref != 'refs/heads/master' }} - uses: khalford/check-version-action@main + uses: stfc/check-version-action@main with: app_version_path: "cloud-chatops/version.txt" docker_compose_path: "cloud-chatops/docker-compose.yaml"