denoland / deployctl

Command line tool for Deno Deploy
https://deno.com/deploy
MIT License
352 stars 58 forks source link

deployctl is not able to read env secret in GitHub Action #298

Closed iShibi closed 8 months ago

iShibi commented 8 months ago

I have set the Deno Deploy access token as DENO_DEPLOY_TOKEN on GitHub and I still get this error:

Entrypoint: file:///src/main.ts
Error: APIError: The authorization token is not valid.
magurotuna commented 8 months ago

Can you share your GitHub Actions workflow file? Also, setting DENO_DEPLOY_TOKEN is not required in most cases, as described in https://github.com/denoland/deployctl/blob/main/action/README.md#usage:

You do not need to set up any secrets for this to work.

You do need to link your GitHub repository to your Deno Deploy project. You have to choose the "GitHub Actions" deployment mode in your project settings on https://dash.deno.com/. Read Deno Deploy documenation for more information.

Can you make sure to link your repository to the Deno Deploy project?

iShibi commented 8 months ago

Here is the workflow:

name: Deploy
on:
  push:
    branches: [main]
  pull_request:
    branches: main

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    permissions:
      id-token: write # Needed for auth with Deno Deploy
      contents: read # Needed to clone the repository

    steps:
      - name: Clone repository
        uses: actions/checkout@v4

      - name: Install Deno
        uses: denoland/setup-deno@v1
        with:
          deno-version: v1.x

      - name: Build step
        run: "deno task build" # 📝 Update the build command(s) if necessary

      - name: Upload to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: "tdotin" # 📝 Update the deploy project name if necessary
          entrypoint: "./main.ts" # 📝 Update the entrypoint if necessary

The reason I want to set the token is because I'm using fresh with tailwindcss: https://tdotin.deno.dev

iShibi commented 8 months ago

Okay, it's working now. Here is what I did:

  1. I went to project settings in Deno Deploy and changed git integration from "Automatic" to "Github Action". This created a new "Production" environment on my repo.
  2. I created an env secret "DENO_DEPLOY_TOKEN" in this "Production" environment and saved the access token in it.
magurotuna commented 8 months ago

Glad to hear that you got it working. Closing as it's resolved, feel free to reopen or create a new issue if there's another question.