From 087acdfd21678af4a4262591f800f2d0ec44c0ca Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Fri, 25 Oct 2024 10:12:43 +0300 Subject: [PATCH] new infra action --- .../login_virtualmonitor-app(login-dev).yml | 51 ------------------ .github/workflows/virtualmonitor-dev.yml | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/login_virtualmonitor-app(login-dev).yml create mode 100644 .github/workflows/virtualmonitor-dev.yml diff --git a/.github/workflows/login_virtualmonitor-app(login-dev).yml b/.github/workflows/login_virtualmonitor-app(login-dev).yml deleted file mode 100644 index 54fc5b5c..00000000 --- a/.github/workflows/login_virtualmonitor-app(login-dev).yml +++ /dev/null @@ -1,51 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions - -name: Build and deploy container app to Azure Web App - virtualmonitor-app(login-dev) - -on: - push: - branches: - - login - workflow_dispatch: - -jobs: - build: - runs-on: 'ubuntu-latest' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to registry - uses: docker/login-action@v1 - with: - registry: https://index.docker.io/v1/ - username: ${{ secrets.AzureAppService_ContainerUsername_6b5e01eccaae47b08187c1feee8237ee }} - password: ${{ secrets.AzureAppService_ContainerPassword_edc85d920c364aa6ae72a97dbbbd3f4c }} - - - name: Build and push container image to registry - uses: docker/build-push-action@v2 - with: - push: true - tags: index.docker.io/hsldevcom/digitransit-virtualmonitor:${{ github.sha }} - file: ./Dockerfile - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'login-dev' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'virtualmonitor-app' - slot-name: 'login-dev' - publish-profile: ${{ secrets.AzureAppService_PublishProfile_e63317ffc1b84f30a47d682d9b7a27cd }} - images: 'index.docker.io/hsldevcom/digitransit-virtualmonitor:${{ github.sha }}' \ No newline at end of file diff --git a/.github/workflows/virtualmonitor-dev.yml b/.github/workflows/virtualmonitor-dev.yml new file mode 100644 index 00000000..70f22e3a --- /dev/null +++ b/.github/workflows/virtualmonitor-dev.yml @@ -0,0 +1,54 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: DEV - increment version and deploy + +on: + push: + branches: + - next + +jobs: + version-increment: + runs-on: ubuntu-latest + if: "!startsWith(github.event.head_commit.message, '[DEPLOY]')" + + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GIT_SECRET }} + - run: git config --global user.name 'Digitransit' + - run: git config --global user.email 'digitransit@hsl.fi' + - name: major + run: npm version major -m "[DEPLOY] %s" + if: "contains(github.event.head_commit.message, '[MAJOR]')" + - name: minor + run: npm version minor -m "[DEPLOY] %s" + if: "contains(github.event.head_commit.message, '[MINOR]')" + - name: patch + run: npm version patch -m "[DEPLOY] %s" + if: "!contains(github.event.head_commit.message, '[MAJOR]') && !contains(github.event.head_commit.message, '[MINOR]')" + - run: git push + + build-and-deploy: + runs-on: 'ubuntu-latest' + if: "startsWith(github.event.head_commit.message, '[DEPLOY]')" + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: azure/docker-login@v1 + with: + login-server: https://index.docker.io/v1/ + username: ${{ secrets.AzureAppService_ContainerUsername_43e4c8bef39f4f7d9da4f67dc0bafa48 }} + password: ${{ secrets.AzureAppService_ContainerPassword_60e925249e694d2896f1c2a466ddf37d }} + + - run: | + docker build . -t index.docker.io/hsldevcom/digitransit-virtualmonitor:${{ github.sha }} + docker push index.docker.io/hsldevcom/digitransit-virtualmonitor:${{ github.sha }} + + - name: Deploy to Azure Web App + uses: azure/webapps-deploy@v2 + with: + app-name: 'lwa-virtualmonitor-dev-weu' + publish-profile: ${{ secrets.AZURE_DEV_2024_PUBLISHPROFILE }} + images: 'index.docker.io/hsldevcom/digitransit-virtualmonitor:${{ github.sha }}'