Skip to content

chore(deps): update typescript-eslint monorepo to v8 (major) #805

chore(deps): update typescript-eslint monorepo to v8 (major)

chore(deps): update typescript-eslint monorepo to v8 (major) #805

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: (PR)build and publish image to Functions
on:
pull_request:
branches: [ master ]
paths:
- 'Azure/Functions/**'
- 'Azure/Vue/**'
- '.github/**/*.yml'
env:
node-version: 13.10.1
dotnet: 6.0.300
registry: ghcr.io
image: weatherdisp
functionsApp: WeatherInfo
jobs:
CancelPreviousRuns:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
Prepare:
name: Prepare environment variable
runs-on: ubuntu-latest
outputs:
SLOT_NAME: ${{github.event.number}}-${{steps.run.outputs.safeBranch}}
BRANCH: ${{steps.run.outputs.safeBranch}}
TAG_NAME: ${{steps.run.outputs.safeBranch}}-${{steps.run.outputs.stag}}
env:
HEAD_REF: ${{github.head_ref}}
STAG: ${{github.event.pull_request.head.sha}}
steps:
- id: run
run: |
DATA=${HEAD_REF##*/}
echo "::set-output name=safeBranch::`echo $DATA | sed -E 's/[^a-zA-Z0-9]/\-/g'`"
echo "::set-output name=stag::${STAG::7}"
Create_Slot:
name: Create Azure functions slot if PR opened
runs-on: ubuntu-latest
needs: Prepare
steps:
- name: 'Login via Azure CLI'
if: github.event.action == 'opened' || github.event.action == 'reopened'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Env'
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
echo RESOURCE_GROUP=`az functionapp list | jq -r '.[] | select(.name =="${{env.functionsApp}}") | .resourceGroup'` >> $GITHUB_ENV
- name: 'Create Azure functions slot'
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
az functionapp deployment slot create --name ${{env.functionsApp}} --slot ${{needs.Prepare.outputs.SLOT_NAME}} --configuration-source ${{env.functionsApp}} --resource-group $RESOURCE_GROUP > /dev/null
Build_frontend:
name: Build frontend using Vue.
runs-on: ubuntu-latest
defaults:
run:
working-directory: Azure/Vue/weatherdisp
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build
run: yarn run build
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: vue
path: Azure/Vue/weatherdisp/dist/index.html
Build_runtime:
name: Build functions.
runs-on: ubuntu-latest
defaults:
run:
working-directory: Azure/Functions/WeatherDisp
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.dotnet }}
- name: Create Dist
run: mkdir -p dist
- name: Build and publish
run: dotnet publish *.csproj --output dist
- name: Copy Image magick
run: cp dist/bin/runtimes/linux-x64/native/Magick.Native-Q8-x64.dll.so dist/bin/Magick.Native-Q8-x64.dll.so
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: functions
path: Azure/Functions/WeatherDisp/dist
Build_and_publish_image:
name: Build and publish image.
runs-on: ubuntu-latest
needs: [Prepare, Build_frontend, Build_runtime]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Download frontend artifact
uses: actions/download-artifact@v2
with:
name: vue
path: images/artifacts/dist
- name: Download runtime artifact
uses: actions/download-artifact@v2
with:
name: functions
path: images/artifacts
- name: Prepare
id: prep
run: |
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: build image and push to GitHub Container Registry
uses: docker/build-push-action@v2
with:
push: true
context: images
tags: |
${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:latest
${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{ steps.prep.outputs.version }}
${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.BRANCH}}-latest
${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.TAG_NAME}}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
DeployPR:
name: Deploy functions container from PR
needs: [Prepare, Create_Slot, Build_and_publish_image]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: GitHub Container Registry login
uses: azure/docker-login@v1
with:
login-server: ${{ env.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy PR container'
id: fa
uses: Azure/functions-container-action@v1
with:
app-name: ${{ env.functionsApp }}
image: ${{ env.registry }}/${{ github.repository_owner }}/${{ env.image }}:${{needs.Prepare.outputs.TAG_NAME}}
slot-name: ${{needs.Prepare.outputs.SLOT_NAME}}
- name: 'comment access url'
uses: actions/github-script@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'URL is ${{steps.fa.outputs.app-url}}/api/WeatherInfo'
})