File size: 1,825 Bytes
87b7cea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Build & Deploy

on:
  push:
    branches:
    - master
  schedule:
    - cron: '0 * * * *'  # This will make the workflow run every hour

jobs:
  update-from-blob:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@v2

      - name: 'Download Blob from Azure Storage'
        uses: wbkcode/WarbaBotf@master
        with:
          connection-string: ${{ secrets.AZURE_BLOB_CONNECTION_STRING }}
          container-name: "warbadataset"
          blob-name: "data.csv"
          download-path: "."

      - name: 'Commit and push'
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add data.csv
          git commit -m "Updated data.csv from Azure Blob Storage" || echo "No changes to commit"
          git push

  build-and-deploy:
    needs: update-from-blob
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@main

      - name: 'Login to Azure CLI'
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: 'Build and Push Docker Image'
        uses: azure/docker-login@v1
        with:
          login-server: botapp.azurecr.io
          username: ${{ secrets.REGISTRY_USERNAME }}
          password: ${{ secrets.REGISTRY_PASSWORD }}
      - run: |
          docker build -t botapp.azurecr.io/app:${{ github.sha }} .
          docker push botapp.azurecr.io/app:${{ github.sha }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: WarbaBot
          publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
          images: 'botapp.azurecr.io/app:${{ github.sha }}'