Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions deploy artifacts

Below workflow fails when deploying the artifacts to S3. In the last line, in the deployment job, it's complaining that ./build doesn't exist, probably because it can't find the artifacts.

The user-provided path ./build does not exist.
##[error]Process completed with exit code 255.

How do I make it recognise the artifacts created in the build job?

name: Build and deploy
on:
  push:
    branches:
      - master
jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        node-version: [10.x]
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - run: |
          npm i -D
          npm test --if-present
          npm run build:prod
        env:
          CI: true
      - name: Upload Artifact
        uses: actions/upload-artifact@master
        with:
          name: build
          path: build
  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master
      - name: Deploy to S3
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        run: |
          aws s3 cp \
          --recursive \
          --acl public-read \
          --region ap-southeast-2 \
          ./build s3://example
like image 832
ChrisRich Avatar asked Aug 09 '26 05:08

ChrisRich


1 Answers

You need to download the artifact in the deploy job. See the actions/download-artifact action.

  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master
      - name: Download Artifact
        uses: actions/download-artifact@master
        with:
          name: build
          path: build
      - name: Deploy to S3
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        run: |
          aws s3 cp \
          --recursive \
          --acl public-read \
          --region ap-southeast-2 \
          ./build s3://example
like image 194
peterevans Avatar answered Aug 11 '26 12:08

peterevans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!