This repository was 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
116 lines (101 loc) · 3.52 KB
/
deployment.yml
File metadata and controls
116 lines (101 loc) · 3.52 KB
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
111
112
113
114
115
116
name: Deployment
on:
workflow_call:
inputs:
exclude-labels:
description: 'Labels of issues and PRs that should be excluded from the changelog.'
default: 'duplicate,question,invalid,wontfix,skip-changelog'
type: string
release-branch:
description: 'The branch to limit the PRs to'
default: 'release'
type: string
main-branch:
description: 'The main branch that will be updated after deployment'
type: string
default: 'main'
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/deployments@v0.6.1
id: start_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: release
- name: Checkout
uses: actions/checkout@v3
- 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/deployments@v0.6.1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.start_deployment.outputs.deployment_id }}
update_changelog_in_main:
uses: codenamephp/workflows.common/.github/workflows/update-changelog.yml@production
with:
ref: ${{inputs.main-branch}}
exclude-labels: ${{inputs.exclude-labels}}
release-branch: ${{inputs.release-branch}}
update_default_branch:
name: Update default branch after published release
runs-on: ubuntu-latest
needs:
- deploy
- update_changelog_in_main
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pull request
uses: repo-sync/pull-request@v2
with:
source_branch: ${{inputs.release-branch}}
destination_branch: ${{inputs.main-branch}}
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/delete-tag-and-release@v0.2.0
with:
tag_name: ${{ github.event.release.tag_name }}
delete_release: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set release to draft
uses: tubone24/update_release@v1.2.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
draft: true