Merge pull request #9 from PilotChalkanov/feature/cicd #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a container and deploy it to an Azure Functions App on Linux when a commit is pushed to your default branch. | |
name: Deploy container to Azure Functions App | |
on: | |
push: | |
branches: ["master"] | |
permissions: | |
contents: read | |
env: | |
AZURE_FUNCTIONAPP_NAME: 'iochalki' # set this to your function app name on Azure | |
LOGIN_SERVER: 'docker.io' # set this to login server for your private container registry (e.g. 'contoso.azurecr.io', 'index.docker.io' ) | |
REGISTRY: 'nikchalkanov' # set this to proper value for REGISTRY | |
IMAGE: 'iochalki' # set this to proper value for IMAGE | |
TAG: 'v0.1.0' # set this to proper value for TAG | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v3 | |
- name: 'Login via Azure CLI' | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: 'Docker Login' | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ env.LOGIN_SERVER }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: 'Import GPG Key' | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_KEY }} | |
passphrase: ${{ secrets.GPG_PASS }} | |
- name: 'list keys' | |
run: gpg -K | |
- name: 'Compose Customized Docker Image' | |
shell: bash | |
run: | | |
docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.TAG }} | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.TAG }} | |
- name: 'Run Azure Functions Container Action' | |
uses: Azure/functions-container-action@v1 | |
id: fa | |
with: | |
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} | |
image: ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.TAG }} | |
- name: 'Published functionapp url' | |
run: | | |
echo "${{ steps.fa.outputs.app-url }}" | |
- name: Azure logout | |
run: | | |
az logout |