From 0fbfaeef1365977522c51bca1d95fac8642eb1af Mon Sep 17 00:00:00 2001 From: astroanu Date: Thu, 4 Apr 2024 13:17:47 +0200 Subject: [PATCH] update workflow --- .github/actions/build/action.yml | 28 +++++++++++++++++++++ .github/actions/deploy/action.yml | 20 +++++++++++++++ .github/workflows/deploy-dev.yml | 20 +++++++++++++++ .github/workflows/deploy-prod.yml | 41 ++----------------------------- 4 files changed, 70 insertions(+), 39 deletions(-) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/deploy/action.yml create mode 100644 .github/workflows/deploy-dev.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..e6b0e5d --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,28 @@ +name: Build +description: Build + +runs: + using: composite + steps: + - name: Install dependencies + run: npm i + shell: | + cd vue + npm i -g yarn + yarn install + yarn build + + - name: Build + run: | + if expr "${{ inputs.target }}" : "Dev" >/dev/null; then + npm run build; + fi + if expr "${{ inputs.target }}" : "Prod" >/dev/null; then + npm run build:prod; + fi + shell: bash + + - uses: actions/upload-artifact@master + with: + name: buid-artifact + path: vue/dist diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml new file mode 100644 index 0000000..6ca58a0 --- /dev/null +++ b/.github/actions/deploy/action.yml @@ -0,0 +1,20 @@ +name: Deploy +description: Deploy + +runs: + using: composite + steps: + - uses: actions/download-artifact@master + with: + name: buid-artifact + path: vue/dist + + - uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.ASTRONOMY_API_DEMO_AWS_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: 'us-east-1' + SOURCE_DIR: 'vue/dist' \ No newline at end of file diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml new file mode 100644 index 0000000..2eec53e --- /dev/null +++ b/.github/workflows/deploy-dev.yml @@ -0,0 +1,20 @@ +name: Deploy + +on: + push: + branches: [ "dev" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/deploy \ No newline at end of file diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index d09371a..12b58ea 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -3,54 +3,17 @@ name: Deploy on: push: branches: [ "master" ] - pull_request: - branches: [ "master" ] jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] steps: - - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Build - run: | - cd vue - npm i -g yarn - yarn install - yarn build - - - uses: actions/upload-artifact@master - with: - name: buid-artifact - path: vue/dist + - uses: ./.github/actions/build deploy: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - - uses: actions/download-artifact@master - with: - name: buid-artifact - path: vue/dist - - - uses: jakejarvis/s3-sync-action@master - with: - args: --acl public-read --follow-symlinks --delete - env: - AWS_S3_BUCKET: ${{ secrets.ASTRONOMY_API_DEMO_AWS_S3_BUCKET }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: 'us-east-1' - SOURCE_DIR: 'vue/dist' \ No newline at end of file + - uses: ./.github/actions/deploy \ No newline at end of file