Test Deploy workllow AWS #1
Workflow file for this run
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
name: Deploy Development App | |
on: | |
workflow_call: | |
push: | |
branches: | |
- develop-aws | |
- feature/Implementação-Workflow-to-Deploy-App-in-AWS | |
permissions: | |
contents: read | |
jobs: | |
build_and_test_net: | |
name: Build and Test .Net App | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache .NET packages | |
uses: actions/cache@v3 | |
id: dotnet-cache | |
with: | |
path: ~/.nuget/packages | |
key: dotnet-packages-${{ github.repository }} | |
restore-keys: dotnet-packages-${{ github.repository }} | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
if: steps.dotnet-cache.outputs.cache-hit != 'true' | |
with: | |
dotnet-version: 7.0.x | |
- name: Build and Restore App | |
run: dotnet build ./HomeBrokerSPA/HomeBrokerSPA.csproj --restore | |
continue-on-error: false | |
trigger_build_and_test: | |
name: Build and Test | |
uses: alexfariakof/Home_Broker_Chart/.github/workflows/build_and_test.yml@main | |
secrets: inherit | |
deploy: | |
needs: build_and_test_net | |
name: Publish App in AWS | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
env: | |
DOCKER_CLI_AGGREGATE: 1 | |
run: | | |
docker-compose -f docker-compose.dev.yml build | |
continue-on-error: false | |
- name: Push Docker image to Docker Hub | |
env: | |
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_CLI_AGGREGATE: 1 | |
run: | | |
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker push alexfariakof/homebrokerspa-dev-img | |
continue-on-error: false | |
- name: Execute SSH Commands into EC2 | |
env: | |
EC2_HOST: ${{ secrets.EC2_HOST }} | |
EC2_USERNAME: ${{ secrets.EC2_USERNAME }} | |
AWS_SSH_KEY: ${{ secrets.AWS_SSH_KEY }} | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
port: 22 | |
script: | | |
./scripts/hb-spa.dev.sh | |