[ Experiments ]

Printing secrets in _Github Actions_

Created:

Updated:

Read: 4 min (702 words)

Tags:

In this post we will see how we can print secrets in Github Actions.

I will be using the following Github repository: https://github.com/romeosarkar10x-experiment/printing-secrets

Creating a secret

Creating a workflow

The above workflow directly echoes the secret by running the echo command.

The following output is generated:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: check, build and deploy to cloudflare pages

on:
  push:
    branches:
      - main

env:
  DART_SASS_VERSION: 1.86.3

jobs:
  check-build-and-deploy:
    runs-on: [self-hosted, Linux, X64]
    environment: production

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

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: "23"

      - name: install dependencies
        run: npm install

      - name: check formatting
        run: npm run check-format

      - name: install hugo
        uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: "latest"

      - name: install dart-sass
        uses: dw-labs-org/dart-sass-gha@v1

      - name: build hugo site
        run: |
          echo building hugo site at $(date)
          hugo

      - name: install wrangler
        run: npm install -g wrangler

      - name: deploy to cloudflare pages
        run: wrangler pages deploy ./public --project-name=expt --branch=main --commit-dirty=true
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Set up job
  • Current runner version: '2.323.0'
  • Runner name: 'romeo-homelab-runner'
  • Machine name: '79ae2dd42848'
  • GITHUB_TOKEN Permissions
    • Contents: read
    • Metadata: read
    • Packages: read
  • Secret source: Actions
  • Prepare workflow directory
  • Prepare all required actions
  • Getting action download info
  • Download action repository 'actions/checkout@v4' (SHA:11bd71901bbe5b1630ceea73d27597364c9af683)
  • Download action repository 'actions/setup-node@v4' (SHA:49933ea5288caeca8642d1e84afbd3f7d6820020)
  • Download action repository 'peaceiris/actions-hugo@v3' (SHA:75d2e84710de30f6ff7268e08f310b60ef14033f)
  • Download action repository 'dw-labs-org/dart-sass-gha@v1' (SHA:d5c4c43545a79eaaa11cb4ec8363462702346184)
  • Getting action download info
  • Download action repository 'robinraju/release-downloader@v1' (SHA:daf26c55d821e836577a15f77d86ddc078948b05)
  • Complete job name: check-build-and-deploy
checkout repository
  • Run actions/checkout@v4
    • with:
    • repository: romeosarkar10x/expt
    • token: ***
    • ssh-strict: true
    • ssh-user: git
    • persist-credentials: true
    • clean: true
    • sparse-checkout-cone-mode: true
    • fetch-depth: 1
    • fetch-tags: false
    • show-progress: true
    • lfs: false
    • submodules: false
    • set-safe-directory: true
    • env:
    • DART_SASS_VERSION: 1.86.3
  • Syncing repository: romeosarkar10x/expt
  • Getting Git version info
    • Working directory is '/home/runner/_work/expt/expt'
  • Deleting the contents of '/home/runner/_work/expt/expt'
  • The repository will be downloaded using the GitHub REST API
  • To create a local Git repository instead, add Git 2.18 or higher to the PATH
  • Downloading the archive
  • Writing archive to disk
  • Extracting the archive
  • /usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/_work/expt/expt/d67ce788-499e-4f49-8ea5-316a4feb5a3f -f /home/runner/_work/expt/expt/d67ce788-499e-4f49-8ea5-316a4feb5a3f.tar.gz
  • Resolved version romeosarkar10x-expt-97e8fc0
setup node
  • Run actions/setup-node@v4
    • with:
    • node-version: 23
    • always-auth: false
    • check-latest: false
    • token: ***
    • env:
    • DART_SASS_VERSION: 1.86.3
  • Found in cache @ /home/runner/_work/_tool/node/23.10.0/x64
  • Environment details
    • node: v23.10.0
    • npm: 10.9.2
    • yarn:
install dependencies
  • Run npm install
    • npm install
    • shell: /usr/bin/bash -e {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
  • added 3 packages, and audited 4 packages in 1s
  • 1 package is looking for funding
  • run `npm fund` for details
  • found 0 vulnerabilities
check formatting
  • Run npm run check-format
    • npm run check-format
    • shell: /usr/bin/bash -e {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
  • > [email protected] check-format
  • > npx prettier --check "**/*.{html,css,js,json,yaml,yml,md}"
  • Checking formatting...
  • All matched files use Prettier code style!
install hugo
  • Run peaceiris/actions-hugo@v3
    • with:
    • hugo-version: latest
    • extended: false
    • env:
    • DART_SASS_VERSION: 1.86.3
  • Hugo version: 0.146.5
  • /usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/actions_hugo/_temp -f /home/runner/_work/_temp/3cf051e0-a4d3-4e3b-af99-370f26015628
  • /home/runner/actions_hugo/bin/hugo version
  • hugo v0.146.5-61328976e11cbb9d906b4a790b8a7cd25b2a914f linux/amd64 BuildDate=2025-04-15T17:54:38Z VendorInfo=gohugoio
install dart-sass
  • Run dw-labs-org/dart-sass-gha@v1
    • with:
    • version: latest
    • env:
    • DART_SASS_VERSION: 1.86.3
  • Run robinraju/release-downloader@v1
    • with:
    • repository: sass/dart-sass
    • latest: true
    • filename: dart-sass-*-linux-x64.tar.gz
    • tarBall: false
    • zipBall: false
    • extract: true
    • preRelease: false
    • out-file-path: .
    • token: ***
    • github-api-url: https://api.github.com
    • env:
    • DART_SASS_VERSION: 1.86.3
  • Fetching latest release for repo sass/dart-sass
  • Found latest release version: 1.86.3
  • Downloading file: dart-sass-1.86.3-linux-x64.tar.gz to: /home/runner/_work/expt/expt
  • Extracted dart-sass-1.86.3-linux-x64.tar.gz to /home/runner/_work/expt/expt
  • Done: /home/runner/_work/expt/expt/dart-sass-1.86.3-linux-x64.tar.gz
  • Run echo "$(pwd)/dart-sass" >> $GITHUB_PATH
    • echo "$(pwd)/dart-sass" >> $GITHUB_PATH
    • shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
build hugo site
  • Run echo building hugo site at $(date)
    • echo building hugo site at $(date)
    • hugo
    • shell: /usr/bin/bash -e {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
  • building hugo site at Thu Apr 17 17:26:18 UTC 2025
  • Start building sites …
  • hugo v0.146.5-61328976e11cbb9d906b4a790b8a7cd25b2a914f linux/amd64 BuildDate=2025-04-15T17:54:38Z VendorInfo=gohugoio
  • WARN Hugo front matter key "author" is overridden in params section.
  • You can suppress this warning by adding the following to your site configuration:
  • ignoreLogs = ['warning-frontmatter-params-overrides']
  • | EN
  • -------------------+-----
  • Pages | 57
  • Paginator pages | 0
  • Non-page files | 1
  • Static files | 13
  • Processed images | 0
  • Aliases | 0
  • Cleaned | 0
  • Total in 603 ms
install wrangler
  • Run npm install -g wrangler
    • npm install -g wrangler
    • shell: /usr/bin/bash -e {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
  • changed 50 packages in 26s
  • 5 packages are looking for funding
  • run `npm fund` for details
deploy to cloudflare pages
  • Run wrangler pages deploy ./public --project-name=expt --branch=main --commit-dirty=true
    • wrangler pages deploy ./public --project-name=expt --branch=main --commit-dirty=true
    • shell: /usr/bin/bash -e {0}
    • env:
    • DART_SASS_VERSION: 1.86.3
    • CLOUDFLARE_API_TOKEN: ***
  • Uploading... (41/81)
  • Uploading... (54/81)
  • Uploading... (67/81)
  • Uploading... (81/81)
  • ✨ Success! Uploaded 40 files (41 already uploaded) (3.25 sec)
  • 🌎 Deploying...
  • ✨ Deployment complete! Take a peek over at https://52502d6b.expt-fl6.pages.dev
Post setup node
  • Post job cleanup.
Post checkout repository
  • Post job cleanup.
Complete job
  • Cleaning up orphan processes