actions / upload-artifact

MIT License
3.26k stars 739 forks source link

create-deployment-artifacts No files were found with the provided path #498

Open hendisantika opened 10 months ago

hendisantika commented 10 months ago

What happened?

[create-deployment-artifacts](https://github.com/hendisantika/portofolio/actions/runs/7498016051/job/20412493662#step:5:11)
No files were found with the provided path: ec064950a7cdf819fd8a5d513cc7904d30eb6401.tar.gz. No artifacts will be uploaded.

Here my github action:

name: Automated Release Deployment

on:
  push:
    branches:
      - main
      - 'feature/deploy'

env:
  NODE_VERSION: 21.5.0
  IP_ADDRESS: "103.251.44.145"

jobs:
  test-application:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Test Application
        uses: actions/setup-node@v4
        with:
          node-version: ${{env.NODE_VERSION}}
          cache: 'npm'
      - run: |
          npm install
          npm run build
  #          npm test

  create-deployment-artifacts:
    needs: test-application
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build App Artifacts
        env:
          GITHUB_SHA: ${{ github.sha }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{env.NODE_VERSION}}
          cache: 'npm'
      - run: |
          touch .env
          echo APP_DOMAIN=https://hendisantika.my.id >> .env
          echo RELEASE_VERSION=${GITHUB_REF} >> .env
          echo GITHUB_SHA=${GITHUB_SHA} >> .env
          npm install
          npm run build
          cp .env .output/server/.env

      - name: Store app-artifacts for distribution
        uses: actions/upload-artifact@v4
        with:
          name: app-artifacts
          path: ${{ github.sha }}.tar.gz
  #          path: .output

  prepare-release-on-servers:
    needs: create-deployment-artifacts
    name: "Prepare release on INT server"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: app-artifacts
          #          path: ${{ github.sha }}.tar.gz
          path: .output

      #      - run: tar.gz -zxvf ${{ github.sha }}.tar.gz .
      - run: zip -r app-artifacts.zip build/

      - uses: ncipollo/release-action@v1
        with:
          #          artifacts: ${{ github.sha }}.tar.gz
          artifacts: "app-artifacts.zip"

      - name: Upload app-artifacts
        uses: appleboy/scp-action@master
        with:
          host: ${{ env.IP_ADDRESS}}
          port: ${{ secrets.SSH_PORT }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          #          source: ${{ github.sha }}.tar.gz
          source: app-artifacts.zip
          target: /var/www/portofolio/artifacts

      - name: Extract archive and create directories
        uses: appleboy/ssh-action@master
        env:
          GITHUB_SHA: ${{ github.sha }}
        with:
          host: ${{env.IP_ADDRESS}}
          username: "root"
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: "22"
          envs: GITHUB_SHA
          script: |
            mkdir -p "/var/www/portofolio/releases/${GITHUB_SHA}"
            tar xzf /var/www/portofolio/artifacts/${GITHUB_SHA}.tar.gz -C "/var/www/portofolio/releases/${GITHUB_SHA}"
            tar xzf /var/www/portofolio/artifacts/${GITHUB_SHA}-database.tar.gz -C "/var/www/portofolio"
            rm -rf /var/www/portofolio/artifacts/${GITHUB_SHA}.tar.gz

  activate-release:
    name: "Activate release"
    runs-on: ubuntu-latest
    needs: prepare-release-on-servers
    steps:
      - name: Activate Release
        uses: appleboy/ssh-action@master
        env:
          RELEASE_PATH: /var/www/portofolio/releases/${{ github.sha }}
          ACTIVE_RELEASE_PATH: /var/www/portofolio/live
        with:
          host: ${{env.IP_ADDRESS}}
          username: "root"
          key: ${{ secrets.SSH_KEY }}
          port: "22"
          envs: RELEASE_PATH,ACTIVE_RELEASE_PATH
          script: |
            ln -s -n -f $RELEASE_PATH $ACTIVE_RELEASE_PATH
            systemctl restart hendisantika.my.id
            chown -R www-data:www-data ${RELEASE_PATH}

  clean-up:
    name: "Clean up old versions"
    runs-on: ubuntu-latest
    needs: activate-release
    steps:
      - name: clean up old releases
        uses: appleboy/ssh-action@master
        with:
          host: ${{env.IP_ADDRESS}}
          username: "root"
          key: ${{ secrets.SSH_KEY }}
          port: "22"
          script: |
            cd /var/www/portofolio/releases && ls -t -1 | tail -n +4 | xargs rm -rf
            cd /var/www/portofolio/artifacts && rm -rf *
      - uses: geekyeggo/delete-artifact@v1
        with:
          name: app-artifacts

But, If I am using

      - name: Store app-artifacts for distribution
        uses: actions/upload-artifact@v4
        with:
          name: app-artifacts
          #path: ${{ github.sha }}.tar.gz
          path: .output

It is uploaded.

any suggestion?

Thanks

What did you expect to happen?

Upload artifacts

How can we reproduce it?

You can clone my repo https://github.com/hendisantika/portofolio

Anything else we need to know?

I am using github action

What version of the action are you using?

4

What are your runner environments?

linux

Are you on GitHub Enterprise Server? If so, what version?

github.com