From ab60d8f40ec90e289382f61fa11a54ec7dc04e7c Mon Sep 17 00:00:00 2001 From: Jekabs Karklins <58165815+jekabs-karklins@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:50:49 +0100 Subject: [PATCH 1/5] Update and rename test-build.yml to test.yml --- .github/workflows/test-build.yml | 28 --------------------- .github/workflows/test.yml | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/test-build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml deleted file mode 100644 index 34293cdb..00000000 --- a/.github/workflows/test-build.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Test && Build - -on: - pull_request: - branches: [master] - -jobs: - test: - name: Test and build image on PR - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: test - run: | - cp CI/ESS/docker-compose.gitlab.yaml docker-compose.yaml - docker-compose down --remove-orphans - docker-compose pull - docker-compose up --build --exit-code-from scicat-backend - docker-compose down - - - name: Build - uses: docker/build-push-action@v3 - with: - context: . - push: false - tags: test_build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..defc00c9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Test + +on: + pull_request: + branches: + - master +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Cache node_modules + id: cache-node-modules + uses: actions/cache@v3 + with: + path: node_modules + key: node-modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: npm ci + + - name: Test + run: | + cp CI/ESS/docker-compose.gitlab.yaml docker-compose.yaml + docker-compose down --remove-orphans + docker-compose pull + docker-compose up --build --exit-code-from scicat-backend + docker-compose down + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Build + uses: docker/build-push-action@v3 + with: + context: . + push: false From 361ff038a4da4b30efb3234bf7b15571cc427f7d Mon Sep 17 00:00:00 2001 From: Jekabs Karklins <58165815+jekabs-karklins@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:58:46 +0100 Subject: [PATCH 2/5] Update test.yml --- .github/workflows/test.yml | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index defc00c9..14b2dfac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,39 +2,24 @@ name: Test on: pull_request: - branches: + branches: - master + jobs: test: - name: Run tests + name: Test and build image on PR runs-on: ubuntu-latest - steps: + steps: - name: Checkout code - uses: actions/checkout@v3 - - - name: Cache node_modules - id: cache-node-modules - uses: actions/cache@v3 - with: - path: node_modules - key: node-modules-${{ hashFiles('package-lock.json') }} - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: npm ci + uses: actions/checkout@v2 - - name: Test + - name: test run: | cp CI/ESS/docker-compose.gitlab.yaml docker-compose.yaml docker-compose down --remove-orphans docker-compose pull docker-compose up --build --exit-code-from scicat-backend docker-compose down - - build: - name: Build - runs-on: ubuntu-latest - steps: - name: Build uses: docker/build-push-action@v3 with: From 8fa3b9690107861758f611c59a26ae1387055320 Mon Sep 17 00:00:00 2001 From: Jekabs Karklins <58165815+jekabs-karklins@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:02:54 +0100 Subject: [PATCH 3/5] Update and rename build-push.yml to deploy.yml --- .github/workflows/build-push.yml | 43 ---------------------------- .github/workflows/deploy.yml | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/build-push.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml deleted file mode 100644 index a8bce0c4..00000000 --- a/.github/workflows/build-push.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Build && Push - -on: - push: - branches: [master] - -jobs: - - build: - name: Build and push Docker image with latest tag - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ghcr.io/scicatproject/backend:latest,ghcr.io/scicatproject/backend:${{ github.sha }} - - gitlab: - name: Deploy - needs: [build] - runs-on: ubuntu-latest - steps: - - name: Trigger ESS pipeline - uses: appleboy/gitlab-ci-action@master - with: - token: ${{ secrets.TOKEN }} - project_id: 1903 - ref: "master" - host: "https://gitlab.esss.lu.se" - debug: true - diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..054b4eb2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,48 @@ +name: Deploy + +on: + push: + branches: + - master + +jobs: + deploy: + name: Build and deploy + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create image tags + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }} + flavor: latest=true # adds :latest tag to outputs.tags + tags: type=sha,format=long,prefix= # adds : tag to outputs.tags + + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + + - name: Trigger ESS pipeline + uses: swapActions/trigger-swap-deployment@v1 + with: + repository: ${{ github.event.repository.name }} + environment: develop + gh-trigger-url: ${{ secrets.GITLAB_TRIGGER_URL }} + gh-token: ${{ secrets.GITLAB_TRIGGER_TOKEN }} + image-tag: ${{ github.sha }} + From 38b844897debd0ffde833c449611b850ae51c569 Mon Sep 17 00:00:00 2001 From: Jekabs Karklins <58165815+jekabs-karklins@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:05:14 +0100 Subject: [PATCH 4/5] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14b2dfac..eb86ca0a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: jobs: test: - name: Test and build image on PR + name: Run tests runs-on: ubuntu-latest steps: - name: Checkout code From 7746f2ce2eed67282a916fd3f74480c37b0695ce Mon Sep 17 00:00:00 2001 From: Jekabs Karklins <58165815+jekabs-karklins@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:06:18 +0100 Subject: [PATCH 5/5] Update deploy.yml --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 054b4eb2..1134ab61 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - uniform-deployment-scripts jobs: deploy: