|
| 1 | +name: Stage the app |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +env: |
| 8 | + DOCKER_IMAGE_NAME: larsbj-azure-ttt |
| 9 | + IMAGE_REGISTRY_URL: docker.pkg.github.com |
| 10 | + ################################################# |
| 11 | + ### USER PROVIDED VALUES ARE REQUIRED BELOW ### |
| 12 | + ################################################# |
| 13 | + ################################################# |
| 14 | + ### REPLACE USERNAME WITH GH USERNAME ### |
| 15 | + AZURE_WEBAPP_NAME: larsbj-ttt-app |
| 16 | + ################################################# |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + if: contains(github.event.pull_request.labels.*.name, 'stage') |
| 21 | + |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v1 |
| 26 | + - name: npm install and build webpack |
| 27 | + run: | |
| 28 | + npm install |
| 29 | + npm run build |
| 30 | + - uses: actions/upload-artifact@master |
| 31 | + with: |
| 32 | + name: webpack artifacts |
| 33 | + path: public/ |
| 34 | + |
| 35 | + Build-Docker-Image: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: build |
| 38 | + name: Build image and store in GitHub Packages |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v1 |
| 42 | + |
| 43 | + - name: Download built artifact |
| 44 | + uses: actions/download-artifact@master |
| 45 | + with: |
| 46 | + name: webpack artifacts |
| 47 | + path: public |
| 48 | + |
| 49 | + - name: create image and store in Packages |
| 50 | + uses: mattdavis0351/actions/[email protected] |
| 51 | + with: |
| 52 | + repo-token: ${{secrets.GITHUB_TOKEN}} |
| 53 | + image-name: ${{env.DOCKER_IMAGE_NAME}} |
| 54 | + |
| 55 | + Deploy-to-Azure: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: Build-Docker-Image |
| 58 | + name: Deploy app container to Azure |
| 59 | + steps: |
| 60 | + - name: "Login via Azure CLI" |
| 61 | + uses: azure/login@v1 |
| 62 | + with: |
| 63 | + creds: ${{ secrets.AZURE_CREDENTIALS }} |
| 64 | + |
| 65 | + - uses: azure/docker-login@v1 |
| 66 | + with: |
| 67 | + login-server: ${{env.IMAGE_REGISTRY_URL}} |
| 68 | + username: ${{ github.actor }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: Deploy web app container |
| 72 | + uses: azure/webapps-deploy@v2 |
| 73 | + with: |
| 74 | + app-name: ${{env.AZURE_WEBAPP_NAME}} |
| 75 | + images: ${{env.IMAGE_REGISTRY_URL}}/${{ github.repository }}/${{env.DOCKER_IMAGE_NAME}}:${{ github.sha }} |
| 76 | + |
| 77 | + - name: Azure logout |
| 78 | + run: | |
| 79 | + az logout |
0 commit comments