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..1134ab61 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Deploy + +on: + push: + branches: + - master + - uniform-deployment-scripts + +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 }} + diff --git a/.github/workflows/test-build.yml b/.github/workflows/test.yml similarity index 83% rename from .github/workflows/test-build.yml rename to .github/workflows/test.yml index 34293cdb..eb86ca0a 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,13 @@ -name: Test && Build +name: Test on: pull_request: - branches: [master] + branches: + - master jobs: test: - name: Test and build image on PR + name: Run tests runs-on: ubuntu-latest steps: - name: Checkout code @@ -19,10 +20,8 @@ jobs: 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