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

Use DENO_DEPLOYMENT_ID in github action??? #149

Closed
RickCogley opened this issue Jan 21, 2023 · 4 comments
Closed

Use DENO_DEPLOYMENT_ID in github action??? #149

RickCogley opened this issue Jan 21, 2023 · 4 comments

Comments

@RickCogley
Copy link

Hi - is there a way to get DENO_DEPLOYMENT_ID so that it can be used in a later step in a GH workflow?

I'm trying this sort of thing:

      - name: Deploy to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: logr-cogley-info # the name of the project on Deno Deploy
          entrypoint: https://deno.land/std@0.140.0/http/file_server.ts
          root: public # Where the built HTML/CSS/JS files are located.
        env:
          LALALA: Deno.env.get("DENO_DEPLOYMENT_ID")
@magurotuna
Copy link
Member

Yes, after the deployment is complete, the deployctl action set the deployment ID so you can use it later.
Suppose we have the workflow file that looks like:

name: Deploy
on: [push]

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

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

      - name: Upload to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: "my-awesome-project"
          entrypoint: "./main.ts"

then we can access the deployment_id via ${{ steps.<deployctl_step_id>.outputs.deployment-id }}, like as follows:

name: Deploy
on: [push]

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

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

      - name: Upload to Deno Deploy
+       id: deploy
        uses: denoland/deployctl@v1
        with:
          project: "my-awesome-project"
          entrypoint: "./main.ts"
+
+     - name: print deployment_id
+       run: echo ${{ steps.deploy.outputs.deployment-id }}

Hope it helps :)

@RickCogley
Copy link
Author

RickCogley commented Jan 21, 2023

@magurotuna thank you very much, that's perfect! I want to include the deployment url in the slack message. Does it return the project name as well? In my slack ping I can do:

https://logr-cogley-info-${{ steps.deploy.outputs.deployment-id }}.deno.dev

But if it returns the project name I'd like to use it, or indeed, the url itself. Tried a few that were logical but, nothing worked. 😸

@RickCogley
Copy link
Author

Right, figured it out. This works:

${{ steps.deploy.outputs.url }}

Doing this, gave me hints:

echo '${{ toJSON(steps) }}'

@RickCogley
Copy link
Author

Wrote up a gist to give a bit more context, and share the deploy.yml file I ended up with, that includes the deployment url in the slack ping:

https://gist.github.com/RickCogley/d4246b9f2817a401f0943149c255697d

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

2 participants