-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 2.49 KB
/
forge_api_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
name: release_forge_api
on:
workflow_call:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.1.2"
bundler-cache: "true"
- name: Checkout
uses: actions/checkout@v2
- name: "Get version"
id: "get_version"
run: |
echo "version=$(grep -o "version = '[^']*'" .version | awk -F"'" '{print $2}' | tr -d \n)" >> $GITHUB_OUTPUT
- name: Install jq and bundle install
run: |
sudo apt-get install jq libjq-dev
export RUBYJQ_USE_SYSTEM_LIBRARIES=1
bundle install
- name: "Bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "Build a new release"
run: |
mkdir -p /home/runner/work/puppet-forge-api/puppet-forge-api/pkg && bundle exec harrison package
- name: "Setup twingate"
uses: twingate/github-action@v1
with:
service-key: ${{ secrets.TWINGATE_KEY }}
- name: "Deploy"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.SSH_PUB_KEY }}" > ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub
version=$(ls -tr pkg | tail -1)
for env in dev stage prod; do
echo "Starting deploy to $env"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cd /home/runner/work/puppet-forge-api/puppet-forge-api && bundle exec harrison deploy pkg/$version --env $env --no-confirm
echo "Successfully deployed to $env"
done
- name: "Generate release notes"
run: |
export GH_HOST=github.com
gh extension install chelnak/gh-changelog
gh changelog get --latest > OUTPUT.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Create release"
run: |
gh release create v${{ steps.get_version.outputs.version }} --title v${{ steps.get_version.outputs.version }} -F OUTPUT.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}