From 9ece762fae60f4cf04c070b0fbf73ab5af63bfd0 Mon Sep 17 00:00:00 2001 From: Daneryl Date: Tue, 13 Aug 2024 08:59:15 +0200 Subject: [PATCH] WIP, testing branch workflow --- .github/workflows/create_testing_release.yml | 60 ++++++++++++++++++++ scripts/testing-release.sh | 23 ++++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/create_testing_release.yml create mode 100755 scripts/testing-release.sh diff --git a/.github/workflows/create_testing_release.yml b/.github/workflows/create_testing_release.yml new file mode 100644 index 0000000000..0bcabda7fc --- /dev/null +++ b/.github/workflows/create_testing_release.yml @@ -0,0 +1,60 @@ +name: Deploy staging + +on: + push: + branches: + - testing + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + create_pre_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: 'testing' + fetch-depth: 0 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - name: Cache node modules + uses: actions/cache@v1.1.2 + with: + path: ./node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + - name: install dependencies + run: yarn install + - name: Cache build + id: cache-build + uses: actions/cache@v2 + with: + path: ./prod + key: ${{ runner.os }}-build-${{ hashFiles('app/**/*.*') }}-${{ hashFiles('database/**/*.*') }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/run.js') }}-${{ hashFiles('**/server.js') }} + - name: build production + if: steps.cache-build.outputs.cache-hit != 'true' + run: yarn production-build + - uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.DEPLOY_KEY }} + - name: Testing release + run: ./scripts/testing-release.sh ${{ secrets.DEPLOY_SERVER }} ${{ secrets.DEPLOY_USER }} ${{ secrets.GH_TOKEN }} + + - name: get-npm-version + id: package-version + uses: martinbeentjes/npm-get-version-action@master + + - name: Create Sentry release + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: uwazi-api + with: + environment: testing + projects: ${{ secrets.SENTRY_PROJECTS }} + version: ${{ steps.package-version.outputs.current-version}} + ignore_empty: true diff --git a/scripts/testing-release.sh b/scripts/testing-release.sh new file mode 100755 index 0000000000..027abf6d9b --- /dev/null +++ b/scripts/testing-release.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# server=${1} +# ssh_user=${2} +gh_token=${3} + +release_version="$(yarn version | grep version: | cut -d" " -f4)" +# previous_tag="$(git tag -l --sort=committerdate | grep "\-rc" | tail -n1)" +# release_notes="$(git log --oneline "$previous_tag".. | grep -v Merge | grep "(.*)" | cut -d" " -f2- | awk '{print "* " $0}')" + +# echo -e "## What's changed\n\n$release_notes\n\n**Full Changelog**: https://github.com/huridocs/uwazi/compare/$previous_tag...$release_version" > release_notes.txt + +tar -czf uwazi_testing_release.tgz ./prod + + # --notes-file release_notes.txt\ + +GITHUB_TOKEN="$gh_token" gh release create "$release_version"\ + --title "Testing $release_version"\ + --prerelease\ + --target testing\ + uwazi_testing_release.tgz + +# scp uwazi_pre_release.tgz "$ssh_user"@"$server":/home/"$ssh_user"/uwazi-operations/release_builds/uwazi_pre_release.tgz