-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from Dmitry-Popovichev/rabbit-consumer-ci
Added scheduled job to build rabbit consumers and increment patch
- Loading branch information
Showing
2 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
#reads the version.txt file and sets the version to the current version | ||
version=`cat ~0/OpenStack-Rabbit-Consumer/version.txt` | ||
|
||
# cuts the $version variable into major, minor and patch numbers, removing the fullstop | ||
major=$(echo $version | cut -f1 -d.) | ||
minor=$(echo $version | cut -f2 -d.) | ||
patch=$(echo $version | cut -f3 -d.) | ||
|
||
#increments the patch by 1 | ||
patch=$((patch + 1)) | ||
|
||
#concatenate the version | ||
newversion="$major.$minor.$patch" | ||
|
||
#overwrites the version.txt file with new new version | ||
printf "$newversion" > ~0/OpenStack-Rabbit-Consumer/version.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Rabbit Consumer Schedule | ||
|
||
# Incrementing the patch version on a schedule to pull latest containers dependencies. | ||
|
||
|
||
on: | ||
schedule: | ||
- cron: "12 10 * * TUE" # Every Tuesday at 10.12am | ||
|
||
jobs: | ||
test_and_lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update --fix-missing | ||
python -m pip install --upgrade pip | ||
# Required for requests-kerberos | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install libkrb5-dev | ||
pip install -r OpenStack-Rabbit-Consumer/requirements.txt | ||
pip install -r OpenStack-Rabbit-Consumer/requirements-test.txt | ||
- name: Run tests | ||
# Using Python3 to launch the module sets up the Python path for us | ||
run: cd OpenStack-Rabbit-Consumer && python3 -m coverage run -m pytest . | ||
|
||
- name: Analyse with pylint | ||
run: | | ||
cd OpenStack-Rabbit-Consumer && pylint $(git ls-files '*.py') | ||
- name: Prepare coverage | ||
run: | | ||
cd OpenStack-Rabbit-Consumer && python -m 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@v2 | ||
|
||
- name: Login to Harbor | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: harbor.stfc.ac.uk | ||
username: ${{ secrets.HARBOR_USERNAME }} | ||
password: ${{ secrets.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@v3 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
context: "{{defaultContext}}:OpenStack-Rabbit-Consumer" | ||
tags: "harbor.stfc.ac.uk/stfc-cloud-staging/openstack-rabbit-consumer:${{ steps.commit_sha.outputs.sha_short }}" | ||
|
||
- name: Inform of tagged name | ||
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud-staging/openstack-rabbit-consumer:${{ steps.commit_sha.outputs.sha_short }}" | ||
|
||
push_release_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@v2 | ||
|
||
- name: Login to Harbor | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: harbor.stfc.ac.uk | ||
username: ${{ secrets.HARBOR_USERNAME }} | ||
password: ${{ secrets.HARBOR_TOKEN }} | ||
|
||
#increments ONLY the patch version using the version_incrememnt.sh script and commits the version.txt file to master | ||
- name: Increment Version | ||
run: bash ${{ github.workspace }}/.github/workflows/bin/version_increment.sh | ||
|
||
- name: Get release tag for later | ||
id: release_tag | ||
run: echo "version=$(cat OpenStack-Rabbit-Consumer/version.txt)" >> $GITHUB_OUTPUT | ||
|
||
- name: Build and push on version change | ||
uses: docker/build-push-action@v3 | ||
if: steps.release_updated.outputs.version == 'true' | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
context: "{{defaultContext}}:OpenStack-Rabbit-Consumer" | ||
tags: "harbor.stfc.ac.uk/stfc-cloud/openstack-rabbit-consumer-schedule:v${{ steps.release_tag.outputs.version }}" | ||
|
||
- name: Inform of tagged name | ||
if: steps.release_updated.outputs.version == 'true' | ||
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud/openstack-rabbit-consumer-schedule:v${{ steps.release_tag.outputs.version }}" | ||
|
||
- name: Commit Changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
add: ${{ github.workspace }}/OpenStack-Rabbit-Consumer/version.txt | ||
default_author: github_actions | ||
committer_name: GitHub Actions | ||
committer_email: [email protected] |