You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This file implements a waiting loop to check for signed files from OSSign.
2
+
3
+
# You need to create the environment "Signatures" (or another name) in your repository
4
+
# and set a waiting period to change the interval. If you do not set a waiting period, this workflow will run again directly after it has finished every time.
5
+
name: OSSign Waiting Loop
6
+
7
+
on:
8
+
# You can also manually start this workflow with the ID printed out in the dispatch workflow
9
+
workflow_dispatch:
10
+
inputs:
11
+
workflow_id:
12
+
description: 'The workflow ID from dispatch'
13
+
required: true
14
+
type: string
15
+
attempt:
16
+
required: false
17
+
description: 'The attempt number'
18
+
type: number
19
+
default: 1
20
+
max_attempts:
21
+
required: false
22
+
description: 'The maximum number of attempts (times the waiting period duration you set in the environment gives the max wait time, e.g. 30 minutes * 48 = 24 hours)'
23
+
type: number
24
+
default: 100
25
+
26
+
jobs:
27
+
wait-and-check:
28
+
runs-on: ubuntu-latest
29
+
30
+
# This job uses an environment with a wait period set in the policy to work around the fact that you cannot pause workflows
31
+
environment: Signatures
32
+
33
+
permissions:
34
+
# Needs actions: write to be able to dispatch workflows
35
+
actions: write
36
+
37
+
# Uses contents: write to be able to read and write workflow artifacts
38
+
contents: write
39
+
steps:
40
+
41
+
# Checks if the attempt threshold was reached, if yes, exits with error
42
+
- name: Check if the threshold has been reached
43
+
shell: bash
44
+
run: |
45
+
if [ ${{ github.event.inputs.attempt }} -gt ${{ github.event.inputs.max_attempts }} ]; then
46
+
echo "Maximum number of attempts reached, exiting."
# This file will build the program and dispatch it to OSSign for signing.
2
+
# It will then start a waiting loop with the workflow file wait-signature to wait for the signed files to appear
3
+
name: Build and Dispatch
4
+
5
+
on:
6
+
push:
7
+
tags: ['*.*.*']
8
+
9
+
jobs:
10
+
build:
11
+
runs-on: windows-latest
12
+
permissions:
13
+
# Needs actions: write to be able to dispatch workflows
14
+
actions: write
15
+
contents: read
16
+
steps:
17
+
# Checkout the code and build the program
18
+
# to make sure everything works as expected
19
+
- uses: actions/checkout@v5
20
+
21
+
- name: Set up Go
22
+
uses: actions/setup-go@v4
23
+
with:
24
+
go-version: '1.25.1'
25
+
26
+
- name: Build the program
27
+
run: go build -o myprogram.exe main.go
28
+
29
+
30
+
# Dispatch a request to the OSSign repo for build + signing
31
+
- name: Dispatch to OSSign
32
+
uses: ossign/actions/workflow/dispatch@main
33
+
with:
34
+
# You receive the username and token from OSSign after your application has been approved
35
+
username: ${{ secrets.OSSIGN_USER }}
36
+
token: ${{ secrets.OSSIGN_TOKEN }}
37
+
38
+
# If you want to keep the workflow running until you have the signed file, you can change this to false
39
+
# Bear in mind that it might sometimes take a while before the dispatch is approved, and this will keep the workflow running and billing if you are using a non-free runner
This is an example workflow with instructions on how to set up the remote approval flow for OSSign
3
+
4
+
## .github/workflows/win-build.yml
5
+
Builds your application and then dispatches a request to OSSign for signing. After dispatching, it starts a waiting loop to wait for the signed files to be available.
6
+
7
+
### Set the secrets
8
+
To use this workflow, you need to set the following secrets in your GitHub repository. You will get these details from OSSign after your application has been approved for signing.
9
+
-`OSSIGN_USER`: Your OSSign username
10
+
-`OSSIGN_TOKEN`: Your OSSign token
11
+
12
+
## .github/workflows/wait-signature.yml
13
+
This workflow is started by the waiting loop in the build workflow. It periodically checks with OSSign to see if the signing is complete. Once the signed files are available, you can add steps to download and use them as needed.
14
+
15
+
### Waiting loop setup
16
+
To set up the waiting loop, start by creating a new environment:
17
+
1. Go to your GitHub repository.
18
+
2. Click on "Settings" > "Environments".
19
+
20
+
3. Create a new environment named `Signatures`. 
21
+
22
+
4. In the environment settings, check the "Wait timer" option and set it to 20 minutes 
23
+
24
+
5. Click "Save protection rules".
25
+
26
+
When setting the secrets, those need to be set outside of the environment.
0 commit comments