Printing secrets in _Github Actions_

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
Go to the repository settings.
Then, on the navigation-bar in the left, goto Secrets and variables.
Then Click on Actions.
Then, on the Secrets section, click on the New repository secret button.
Now, fill in the Name (name of the secret key) and the Secret (value of the secret key), and click on the Add secret button.
This will redirect us back to the Secrets section, where we can see the newly added secret.
Creating a workflow
- Create a file .github/workflows/<filename>.[yml|yaml]
- Write 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 }}