From d8dec430482a182a3d5607127bfc493d62c04c56 Mon Sep 17 00:00:00 2001 From: Iain-S <25081046+Iain-S@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:04:03 +0100 Subject: [PATCH 1/4] cp the DH deploy over deploy and remove the acr deploy --- .github/workflows/deploy-api-acr.yml | 43 -------------------- .github/workflows/deploy-api-dh.yml | 42 -------------------- .github/workflows/deploy.yml | 59 +++++++++++++--------------- 3 files changed, 27 insertions(+), 117 deletions(-) delete mode 100644 .github/workflows/deploy-api-acr.yml delete mode 100644 .github/workflows/deploy-api-dh.yml diff --git a/.github/workflows/deploy-api-acr.yml b/.github/workflows/deploy-api-acr.yml deleted file mode 100644 index 165e0b0..0000000 --- a/.github/workflows/deploy-api-acr.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action -# More GitHub Actions for Azure: https://github.com/Azure/actions -# More info on Python, GitHub Actions, and Azure Functions: https://aka.ms/python-webapps-actions - - -name: Build and push API image to ACR - -on: - release: - types: - - published - workflow_dispatch: - -jobs: - deploy_to_acr: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Get release tag - id: current_release - run: | - CURRENT_RELEASE=${{ github.event.release.tag_name }} - echo "CURRENT_RELEASE=${CURRENT_RELEASE}" >> $GITHUB_ENV - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_RELEASE" - MAJOR_VERSION_NUMBER="${VERSION_PARTS[0]}" - echo "MAJOR_VERSION_NUMBER=${MAJOR_VERSION_NUMBER}" >> $GITHUB_ENV - echo "The current release is $CURRENT_RELEASE" - echo "The current major version number is $MAJOR_VERSION_NUMBER" - - - name: Login to docker - uses: azure/docker-login@v1 - with: - login-server: ${{ secrets.RCTAB_ACR_LOGIN_SERVER }} - username: ${{ secrets.RCTAB_ACR_USERNAME }} - password: ${{ secrets.RCTAB_ACR_PASSWORD }} - - - name: Build and Push current release and latest tag to ACR - run: | - docker build . -t ${{ secrets.RCTAB_ACR_LOGIN_SERVER }}/rctab-api:${{ env.CURRENT_RELEASE }} -t ${{ secrets.RCTAB_ACR_LOGIN_SERVER }}/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.latest - docker push --all-tags ${{ secrets.RCTAB_ACR_LOGIN_SERVER }}/rctab-api diff --git a/.github/workflows/deploy-api-dh.yml b/.github/workflows/deploy-api-dh.yml deleted file mode 100644 index ccdcbfe..0000000 --- a/.github/workflows/deploy-api-dh.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Deploy API image to Docker Hub - -on: - release: - types: - - published - -jobs: - deploy_to_docker_hub: - runs-on: ubuntu-latest - - steps: - - name: Get release tag - id: current_release - run: | - CURRENT_RELEASE=${{ github.event.release.tag_name }} - echo "CURRENT_RELEASE=${CURRENT_RELEASE}" >> $GITHUB_ENV - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_RELEASE" - MAJOR_VERSION_NUMBER="${VERSION_PARTS[0]}" - echo "MAJOR_VERSION_NUMBER=${MAJOR_VERSION_NUMBER}" >> $GITHUB_ENV - echo "The current release is $CURRENT_RELEASE" - echo "The current major version number is $MAJOR_VERSION_NUMBER" - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Login to Docker Hub - id: docker_login - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and Push current release and latest tag to Docker Hub - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile - tags: | - turingrc/rctab-api:${{ env.CURRENT_RELEASE }} - turingrc/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.latest - push: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7f5c563..ccdcbfe 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,47 +1,42 @@ ---- - -name: Publish Docker image +name: Deploy API image to Docker Hub on: release: - # Publish on release types: - published jobs: - docker_build: + deploy_to_docker_hub: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Check that we can build docker container image - run: docker build -t rctab:latest . - - push_to_registry: - needs: docker_build - name: Push Docker image to GitHub Packages - runs-on: ubuntu-latest - timeout-minutes: 30 - - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Login to DockerHub + - name: Get release tag + id: current_release + run: | + CURRENT_RELEASE=${{ github.event.release.tag_name }} + echo "CURRENT_RELEASE=${CURRENT_RELEASE}" >> $GITHUB_ENV + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_RELEASE" + MAJOR_VERSION_NUMBER="${VERSION_PARTS[0]}" + echo "MAJOR_VERSION_NUMBER=${MAJOR_VERSION_NUMBER}" >> $GITHUB_ENV + echo "The current release is $CURRENT_RELEASE" + echo "The current major version number is $MAJOR_VERSION_NUMBER" + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Login to Docker Hub + id: docker_login uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} -# - name: Push to Docker Hub -# uses: docker/build-push-action@v4 -# with: -# context: . -# file: Dockerfile -# tags: turingrc/rctab -# push: true - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + - name: Build and Push current release and latest tag to Docker Hub + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile + tags: | + turingrc/rctab-api:${{ env.CURRENT_RELEASE }} + turingrc/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.latest + push: true From 5d9cf9bc45f13ab396a32756187b47a1a5d802da Mon Sep 17 00:00:00 2001 From: Iain-S <25081046+Iain-S@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:05:23 +0100 Subject: [PATCH 2/4] Check versions match during release --- .github/workflows/deploy.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ccdcbfe..9154d79 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,6 +10,16 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check that tag and package versions match + run: | + PYPROJECT_VERSION=$(sed -n '3p' pyproject.toml | sed "s/version = //") + GITHUB_VERSION=${{ github.event.release.tag_name }} + if [[ "$PYPROJECT_VERSION" != "\"$GITHUB_VERSION\"" ]] + then + echo "pyproject.toml version $PYPROJECT_VERSION doesn't match GitHub version \"$GITHUB_VERSION\"" + exit 1 + fi + - name: Get release tag id: current_release run: | From bae0c837fd3a557ddd6828490bcb3362d4a36271 Mon Sep 17 00:00:00 2001 From: joseph-palmer <22678593+joseph-palmer@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:57:31 +0100 Subject: [PATCH 3/4] Creates prelease and release triggers --- .github/workflows/deploy.yml | 16 ++++- .github/workflows/dev-test-deploy.yml | 86 --------------------------- 2 files changed, 13 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/dev-test-deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9154d79..941b6bc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,6 +10,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Check that tag and package versions match run: | PYPROJECT_VERSION=$(sed -n '3p' pyproject.toml | sed "s/version = //") @@ -31,8 +34,15 @@ jobs: echo "The current release is $CURRENT_RELEASE" echo "The current major version number is $MAJOR_VERSION_NUMBER" - - name: Checkout repository - uses: actions/checkout@v2 + - name: Set pre-release suffix + if: ${{ github.event.release.prerelease }} + run: | + echo "TAG_SUFFIX='prelease'" >> $GITHUB_ENV + + - name: Set release suffix + if: ${{ !github.event.release.prerelease }} + run: | + echo "TAG_SUFFIX='latest'" >> $GITHUB_ENV - name: Login to Docker Hub id: docker_login @@ -48,5 +58,5 @@ jobs: file: Dockerfile tags: | turingrc/rctab-api:${{ env.CURRENT_RELEASE }} - turingrc/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.latest + turingrc/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.${{ env.TAG_SUFFIX }} push: true diff --git a/.github/workflows/dev-test-deploy.yml b/.github/workflows/dev-test-deploy.yml deleted file mode 100644 index 4c9f1b7..0000000 --- a/.github/workflows/dev-test-deploy.yml +++ /dev/null @@ -1,86 +0,0 @@ ---- - -name: develop-test-build-deploy - -on: - push: - branches: develop - -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - python_version: ['3.10'] - - services: - postgres: - image: postgres:11 - env: - POSTGRES_PASSWORD: password - ports: - - 5432:5432 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python_version }} - - - name: Install poetry - uses: abatilo/actions-poetry@v2 - with: - poetry-version: "1.2.2" - - - name: Install dependencies - run: poetry install - - - name: Run main tests - shell: bash - run: scripts/runtests.sh -d -c main - - - name: Run route tests - shell: bash - run: scripts/runtests.sh -d -c routes - - - build: - needs: test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Check that we can build docker container image - run: docker build -t rctab:dev . - - - deploy: - needs: build - runs-on: ubuntu-latest - - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - -# - name: Push to Docker Hub -# uses: docker/build-push-action@v4 -# with: -# context: . -# file: Dockerfile -# tags: turingrc/rctab:dev -# push: true - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} From 4384ffdc8bf2aef10cc35c77823a2c7e83d2e8b5 Mon Sep 17 00:00:00 2001 From: joseph-palmer <22678593+joseph-palmer@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:02:05 +0100 Subject: [PATCH 4/4] changed release types --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 941b6bc..d442429 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,8 @@ name: Deploy API image to Docker Hub on: release: types: - - published + - released + - prereleased jobs: deploy_to_docker_hub: