This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.17 KB
/
deployment.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Deployment
on:
release:
types: [published]
jobs:
deploy:
name: Deploy to chef server and supermarket
runs-on: ubuntu-latest
env:
CHEF_LICENSE: accept-no-persist
steps:
- name: start deployment
uses: bobheadxi/[email protected]
id: start_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: release
- name: Checkout
uses: actions/checkout@v2
- name: install chef
uses: actionshub/chef-install@main
- name: Create key
run: 'echo "$CHEF_KEY" > codenamephp.pem'
env:
CHEF_KEY: ${{secrets.CHEF_KEY}}
- name: Install spork
run: chef exec gem install knife-spork
- name: Get cookbook name
id: get_cookbook_name
run: |
export COOKBOOK_NAME=`chef exec ruby -e 'require "chef/cookbook/metadata"; metadata = Chef::Cookbook::Metadata.new; metadata.from_file("metadata.rb"); puts metadata.name'`
echo "::set-output name=cookbook_name::$COOKBOOK_NAME"
- name: Check cookbook version in metadata
run: knife spork check ${{ steps.get_cookbook_name.outputs.cookbook_name }} -o .. --fail
- name: Deploy to supermarket
run: knife supermarket share ${{ steps.get_cookbook_name.outputs.cookbook_name }} -o ..
- name: Deploy to chef server
run: berks install && berks upload -e test
- name: update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.start_deployment.outputs.deployment_id }}
update_default_branch:
name: Update default branch after published release
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: "master"
- name: create changelog
uses: charmixer/auto-changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude_labels: "duplicate,question,invalid,wontfix,skip-changelog"
- name: commit updated changelog
uses: EndBug/add-and-commit@v7
with:
message: "[CHANGELOG] Updated changelog"
add: "CHANGELOG.md"
signoff: true
branch: master
- name: Create pull request
uses: repo-sync/pull-request@v2
with:
source_branch: "release"
destination_branch: "master"
pr_title: "[Deployment] Update default branch"
pr_label: "skip-changelog"
github_token: ${{ secrets.GITHUB_TOKEN }}
rollback_on_failure:
name: Rollback on failure
runs-on: ubuntu-latest
needs: deploy
if: failure()
steps:
- name: Delete tag
uses: dev-drprasad/[email protected]
with:
tag_name: ${{ github.event.release.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set release to draft
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
draft: true