diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddb35c1..e55a08b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,16 @@ on: workflow_call: + inputs: + store-artifact: + description: 'Whether the built artifact should be stored' + default: false + required: false + type: boolean + artifact-name: + description: 'Name of the artifact, defaults to `built-app`' + default: built-app + required: false + type: string jobs: build: @@ -14,4 +25,11 @@ jobs: - name: Install dependencies run: npm ci - name: Build app - run: npm run build \ No newline at end of file + run: npm run build + - name: Archive build artifacts + if: ${{ inputs.store-artifact }} + uses: actions/upload-artifact@v2 + with: + name: ${{ inputs.artifact-name }} + path: ./build + retention-days: 3 # we only store these for 3 days because they're almost always immediately used \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c7c5824..6cf501d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,10 +4,19 @@ on: push: branches: - main + - feature/fix-pipeline-empty # todo: only for testing + +env: + ARTIFACT_NAME: built-app + BUILD_DIRECTORY: ./build + jobs: build: name: Check Build uses: ./.github/workflows/build.yml + with: + store-artifact: true + artifact-name: $ARTIFACT_NAME deploy: permissions: @@ -17,8 +26,13 @@ jobs: name: Deploy to GitHub Pages runs-on: ubuntu-latest steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: $ARTIFACT_NAME + path: $BUILD_DIRECTORY - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build + publish_dir: $BUILD_DIRECTORY