From 4c7dd0d69eb7df106e4db898d7a48098d673990d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Fri, 22 Nov 2024 21:12:06 +0100 Subject: [PATCH] Copy github workflows --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 16 ----------- .github/workflows/release.yml | 54 +++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3c0465b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: BuildApp +on: + push: + branches: [ ci-cd ] + pull_request: + branches: [ ci-cd ] + workflow_dispatch: +jobs: + build-frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@master + with: + node-version: 20 + - name: Install Angular CLI + run: yarn global add @angular/cli + - name: Configure ng to use yarn + run: ng config --global cli.packageManager yarn + - name: Yarn install + working-directory: Frontend + run: yarn install + - name: Build Angular + working-directory: Frontend + run: ng build --configuration=production + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: frontend + path: Frontend/dist + build-backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup dotnet 6 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Install dependencies + working-directory: WebAPI + run: dotnet restore + - name: Build + working-directory: WebAPI + run: | + dotnet build --configuration Release --no-restore + dotnet publish --configuration Release --framework net8.0 --runtime linux-x64 --self-contained false --output ../build_webapi + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: webapi + path: build_webapi + + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index d637254..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Angular CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: npm install and npm run CI commands - run: | - npm i - ng build --configuration=production diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b9eaa8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release Pipeline + +on: + workflow_dispatch: # Allows manual triggering + +jobs: + release: + name: Release to Server + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Download build artifacts from another workflow (e.g., build pipeline) + - name: Download Frontend Artifacts + uses: actions/download-artifact@v4 + with: + name: frontend # Name of the artifact created in the build pipeline + path: ./artifact # Where to download the artifact + + # Step 2: Download build artifacts from another workflow (e.g., build pipeline) + - name: Download Backend Artifacts + uses: actions/download-artifact@v4 + with: + name: backend # Name of the artifact created in the build pipeline + path: ./artifact # Where to download the artifact + + # Step 3: Replace tokens in files with GitHub secrets + #- name: Replace tokens in files + # run: | + # find ./artifact -type f -exec sed -i "s/{{TOKEN_SECRET}}/${{ secrets.TOKEN_SECRET }}/g" {} \; + + # Step 4: Compress the artifact folder + #- name: Compress files + # run: | + # tar -czvf release_artifact.tar.gz -C ./artifact . + + # Step 5: Set up SSH agent with the private key + #- name: Setup SSH + # uses: webfactory/ssh-agent@v0.5.4 + # with: + # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + # Step 6: Upload the compressed file to the remote server via SCP + #- name: Upload to remote server + # run: | + # scp release_artifact.tar.gz ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:/path/to/destination + + # Step 7: Execute a script on the remote server + #- name: Execute remote script + # run: | + # ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "bash /path/to/destination/deploy.sh"