This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
94 lines (81 loc) · 3.04 KB
/
build-deploy.yml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build and Deploy sub-action
on:
workflow_call:
# Define the inputs required for the action to run
inputs:
# The environment where the deployment should occur
env:
required: true
type: string
description: The environment where the deployment should occur (e.g. dev, staging, prod).
# The awk command to update the version environment variable
awk:
required: true
type: string
description: The awk command to update the version environment variable.
# The rails command for a sanity check
rails:
required: false
type: string
default: echo "continuing."
description: The rails command for a sanity check.
# The branch where the action should be triggered
branch:
required: false
type: string
default: ${{ github.ref }}
description: The branch where the action should be triggered.
# Define the secrets required for the action to run
secrets:
# GitHub Personal Access Token for logging into GitHub
GH_PAT:
description: 'Personal Access Token (PAT) for logging into GitHub'
required: true
# Private key for signing commits and tags with GPG
GPG_PRIVATE_KEY:
description: 'Private key for signing commits and tags with GPG'
required: true
# Passphrase for using the GPG private key
GPG_PASSPHRASE:
description: 'Passphrase for using the GPG private key'
required: true
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
steps:
# Checkout the specified branch from GitHub
- uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
ssh-key: ${{ secrets.GH_PAT }}
# Import the GPG key for signing Git commits and tags
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_tag_gpgsign: true
git_commit_gpgsign: true
# Get the current version from the 'VERSION' file
- name: get Version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
# Sanity check the version we are trying to release
- name: Sanity Check Branch
run: ${{ inputs.rails }}
# Tag the Git repository with the current version
- name: git tag
run: git tag -s ${{ env.VERSION }} -m ${{ env.VERSION }} && git push origin tag ${{ env.VERSION }}
# Rev the version
- name: Update version environment variable
run: echo "VERSION=$(echo $VERSION | ${{ inputs.awk }})" >> $GITHUB_ENV
# Update the 'VERSION' file to reflect the rev'd version
- name: Update VERSION file
run: echo "$VERSION" > VERSION
- uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ inputs.branch }}
commit_message: Rev'd 'VERSION' file to ${{ env.VERSION }}
commit_options: -S
commit_user_email: [email protected]
commit_user_name: ci-dominantstrategies