-
Notifications
You must be signed in to change notification settings - Fork 8
72 lines (67 loc) · 2.8 KB
/
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
name: Auto release PR
on:
push:
tags:
- '*'
workflow_dispatch:
permissions:
contents: write # to create release
pull-requests: write # to create release PR
jobs:
# from https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another
deploy-staging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SGTPOOKI_PAT }}
ref: staging
- name: Fetch all tags
run: git fetch --tags
- name: Get latest tag
id: get_latest_tag
run: echo "tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_OUTPUT
- name: Checkout latest tag
run: git checkout ${{ steps.get_latest_tag.outputs.tag }}
- name: Ensure staging-release branch points to latest tag
run: |
git checkout -B staging-release ${{ steps.get_latest_tag.outputs.tag }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
token: ${{ secrets.SGTPOOKI_PAT }}
base: staging
branch: staging-release
title: 'chore: point staging to release ${{ steps.get_latest_tag.outputs.tag }}'
body: 'This PR points the staging branch to release ${{ steps.get_latest_tag.outputs.tag }}.'
# from https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another
deploy-production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SGTPOOKI_PAT }}
fetch-depth: 0 # Fetch all history so that git commands work correctly
- name: Fetch all branches and tags
run: |
git fetch --all --tags
- name: Get latest tag merged into staging
id: get_latest_tag
run: |
git checkout origin/staging
latest_tag=$(git describe --tags $(git rev-list --tags --merged origin/staging --max-count=1))
echo "tag=$latest_tag" >> $GITHUB_OUTPUT
- name: Checkout latest tag
run: git checkout ${{ steps.get_latest_tag.outputs.tag }}
- name: Ensure production-release branch points to latest tag
run: |
git checkout -B production-release ${{ steps.get_latest_tag.outputs.tag }}
git push origin production-release --force
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
token: ${{ secrets.SGTPOOKI_PAT }}
base: production
branch: production-release
title: 'chore: Point production to release ${{ steps.get_latest_tag.outputs.tag }}'
body: 'This PR points the production branch to release ${{ steps.get_latest_tag.outputs.tag }}.'