diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..86561a7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,118 @@ +name: GitHub Pages +on: + push: + branches: + - v3.5 +jobs: + Approve : + runs-on: ubuntu-latest + environment: build + steps: + - name: Checkout + uses: actions/checkout@v2 + build: + runs-on: ubuntu-latest + needs: Approve + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + - name: Install dependencies + run: | + npm install -g @angular/cli + mkdir user + cd user + ls -la + npm i + npm run build:prod + ls -la + - name: listing + run: | + ls -la + cd dist + ls -la + - name: zipping + uses: papeloto/action-zip@v1 + with: + files: dist/user + dest: user.zip + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: user + path: user.zip + deploy_to_dev: + runs-on: ubuntu-latest + needs: build + if: github.event_name != 'pull_request' + environment: Dev + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Download build + uses: actions/download-artifact@v3 + with: + name: user + - name: Display structure of downloaded files + run: ls -R + - name: Deploy to Server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.KEY }} + SOURCE: "user.zip" + REMOTE_HOST: ${{ secrets.HOST_DNS }} + REMOTE_USER: ${{ secrets.USERNAME }} + TARGET: ${{ secrets.V35_DIR }} + + deploy_to_staging: + runs-on: ubuntu-latest + needs: deploy_to_dev + if: github.event_name != 'pull_request' + environment: Staging + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Download build + uses: actions/download-artifact@v3 + with: + name: user + - name: Display structure of downloaded files + run: ls -R + - name: Deploy to Server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.KEY }} + SOURCE: "user.zip" + REMOTE_HOST: ${{ secrets.HOST_DNS }} + REMOTE_USER: ${{ secrets.USERNAME }} + TARGET: ${{ secrets.STAG_DIR }} + script: sh unzip.sh + + + + deploy_to_prod: + runs-on: ubuntu-latest + needs: deploy_to_staging + if: github.event_name != 'pull_request' + environment: Prod + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Download build + uses: actions/download-artifact@v3 + with: + name: user + - name: Display structure of downloaded files + run: ls -R + - name: Deploy to Server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.KEY }} + SOURCE: "user.zip" + REMOTE_HOST: ${{ secrets.HOST_DNS }} + REMOTE_USER: ${{ secrets.USERNAME }} + TARGET: ${{ secrets.PROD_DIR }} + script: sh unzip.sh diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml deleted file mode 100644 index 89595d8..0000000 --- a/.github/workflows/gh-pages.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: GitHub Pages - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: 14 - - - name: Install dependencies - run: npm install - - - name: Run tests - run: npm run test:headless - - - name: Build - run: npm run build:prod - - - name: Deploy - if: success() - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: dist/angular-github-actions - enable_jekyll: true diff --git a/.github/workflows/sample.yaml b/.github/workflows/sample.yaml new file mode 100644 index 0000000..4bfd536 --- /dev/null +++ b/.github/workflows/sample.yaml @@ -0,0 +1,52 @@ +name: CI + CD + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Compile + run: echo Hello, world! + + DeployDev: + name: Deploy to Development + if: github.event_name == 'pull_request' + needs: [Build] + runs-on: ubuntu-latest + environment: + name: Development + url: 'http://dev.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! + + DeployStaging: + name: Deploy to Staging + if: github.event.ref == 'refs/heads/main' + needs: [Build] + runs-on: ubuntu-latest + environment: + name: Staging + url: 'http://test.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! + + DeployProd: + name: Deploy to Production + needs: [DeployStaging] + runs-on: ubuntu-latest + environment: + name: Production + url: 'http://www.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! diff --git a/.gitignore b/.gitignore index 105c00f..cfd1ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. # compiled output +/user /dist /tmp /out-tsc diff --git a/angular.json b/angular.json index 9c74f96..a7cb462 100644 --- a/angular.json +++ b/angular.json @@ -20,7 +20,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/angular-github-actions", + "outputPath": "dist/user", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", diff --git a/package.json b/package.json index b49012d..4fbf1a9 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "build:prod": "ng build --configuration production --base-href https://rodrigokamada.github.io/angular-github-actions/", + "build:prod": "ng build --configuration production", "watch": "ng build --watch --configuration development", "test": "ng test", "test:headless": "ng test --watch=false --browsers=ChromeHeadless" diff --git a/src/index.html b/src/index.html index 6e0635c..3c533e9 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - Angular Github Actions + Angular Github Actions2