Skip to content

Commit

Permalink
Inclusão da pipeline actions
Browse files Browse the repository at this point in the history
  • Loading branch information
unyleyaosanam committed Apr 26, 2021
1 parent 58e038b commit 2b67728
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/azure_app_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 'Pipeline Azure Web App com container'

on:

push:
branches:
- main

pull_request:

env:
IMAGE_NAME: appmobead01

jobs:
valida-conteudo-docker:
name: 'test'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
push-image-docker:
needs: valida-conteudo-docker

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_REGISTRY_USER }} -p ${{ secrets.DOCKER_REGISTRY_PASSWORD }}

- name: Push image
run: |
IMAGE_ID=osanamgcj/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "$default-branch" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
deploy-app-service-docker:
needs: push-image-docker
runs-on: ubuntu-latest
container: microsoft/azure-cli

steps:
- name: 'Deploy to Azure WebApp'
run: |
az login --service-principal --username 3a6ce6a2-d9ef-40b0-b792-a6f31acee621 --password Mrq8xyiF.jYQGb~A.D2-px6Z~JPwS53u-l --tenant 8f40ba42-dd02-4744-9b4b-3334bf93a647
az account show
az account set -s 136d602b-4347-468c-a58f-81eb3d9b389d
az appservice plan create --name AppSvc-DockerTutorial-plan --resource-group DevOps-rg --is-linux
az webapp create --resource-group DevOps-rg --plan AppSvc-DockerTutorial-plan --name osanamwebapp01 --deployment-container-image-name osanamgcj/appmobead01:main
az webapp show --name osanamwebapp01 --resource-group DevOps-rg

0 comments on commit 2b67728

Please sign in to comment.