Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTIFACT_URL does not support Github Artifacts #18

Open
Chrico opened this issue Oct 9, 2024 · 6 comments
Open

ARTIFACT_URL does not support Github Artifacts #18

Chrico opened this issue Oct 9, 2024 · 6 comments

Comments

@Chrico
Copy link

Chrico commented Oct 9, 2024

When using actions/upload-artifact@v4 and the returned artifact-url from output, it does not work due missing auth for the URL.

Is it possible to support "Github Artifacts" since there is already a GITHUB_TOKEN available and the github.getOctokit(GITHUB_TOKEN) uses it?

The workflow looks like following:

name: InstaWP WordPress Testing

on:
  push:
    branches:
      - insta-wp-built

jobs:
  build-artifact:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Set up node
        uses: actions/setup-node@v4
        with:
          node-version: 18
          registry-url: 'https://npm.pkg.github.com/'
          cache: 'yarn'

      - name: Install dependencies
        run: yarn

      - name: Create Plugin-ZIP
        run: yarn plugin-zip

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: "my-plugin"
          path: ./my-plugin.zip

  create-wp-for-testing:
    needs: build-artifact
    runs-on: ubuntu-latest
    steps:
      - name: Start InstaWP
        uses: instawp/wordpress-testing-automation@main
        with:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          INSTAWP_TOKEN: ${{secrets.INSTAWP_TOKEN}}
          # INSTAWP_TEMPLATE_SLUG: /* snip */
          # REPO_ID: /* snip */
          INSTAWP_ACTION: create-site-template
          ARTIFACT_URL: ${{ steps.build-artifact.artifact-url }}

Links

@vikasprogrammer
Copy link
Contributor

I will check this and get back to you.

@vikasprogrammer
Copy link
Contributor

Where and how do we get this from?

@Chrico
Copy link
Author

Chrico commented Nov 14, 2024

It seems like I kind of miss-understood the ARTIFACT_URL in the code here https://github.com/InstaWP/wordpress-testing-automation/blob/main/src/action.js#L38 . It requires the user to point to a public URL which contains to send that URL in the request data ( override_url ) in order to download the ZIP file with data on the API Server. So you are actually not aware of the GITHUB_TOKEN on your end (API).

But I guess it is still possible in the action to check if the ARTIFACT_URL is a "GitHub Artifact" and download it through the Octokit API. After that you would need to send the ZIP data to your API endpoint as form data. This would require some changes on your API Endpoint to also accept sending of form data.
As an addition, it could be also possible to not provide an URL at all and a local path instead pointing to the ZIP file in the file system. The action could read that local file simply through await fs.readFile(filePath) to send it to the API.

@vikasiwp
Copy link
Contributor

We will see if we can build this, thank you!

@vikasiwp
Copy link
Contributor

We can try a public endpoint such as curl -i -F "files[][email protected]" https://uguu.se/upload

@Chrico
Copy link
Author

Chrico commented Nov 14, 2024

We can try a public endpoint such as curl -i -F "files[][email protected]" https://uguu.se/upload

Maybe not ideal when you work with private repositories and data. 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants