-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (79 loc) · 3.49 KB
/
release.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
name: create new release with changelog
on:
pull_request:
branches:
- 'main'
- 'master'
types: [closed]
env:
DOCKERFILE_PATH: app
DOCKERFILE_TAG: ${{ github.event.pull_request.head.sha }}
REGISTRY_PATH: gcr.io/getindata-images-public/docker-atlantis
REGISTRY_TYPE: "gcr.io" # If not set then will default to Docker Hub
REGISTRY_USERNAME: _json_key
jobs:
release:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- name: Check release label
id: release-label
uses: actions-ecosystem/[email protected]
if: ${{ github.event.pull_request.merged == true }}
- name: Get latest tag
id: get-latest-tag
uses: actions-ecosystem/[email protected]
if: ${{ steps.release-label.outputs.level != null }}
- name: Bump semantic version
id: bump-semver
uses: actions-ecosystem/action-bump-semver@v1
if: ${{ steps.release-label.outputs.level != null }}
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}
- name: Tag release
id: tag-relese
uses: actions-ecosystem/action-push-tag@v1
if: ${{ steps.release-label.outputs.level != null }}
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}"
- name: Login to registry ${{ env.REGISTRY_TYPE }}
uses: docker/[email protected]
if: ${{ steps.release-label.outputs.level != null }}
with:
registry: ${{ env.REGISTRY_TYPE }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Tag final docker image
if: ${{ steps.release-label.outputs.level != null }}
run: |
docker pull ${{ env.REGISTRY_PATH }}:${{ github.event.pull_request.head.sha }}
docker tag ${{ env.REGISTRY_PATH }}:${{ github.event.pull_request.head.sha }} ${{ env.REGISTRY_PATH }}:${{ steps.bump-semver.outputs.new_version }}
docker push ${{ env.REGISTRY_PATH }}:${{ steps.bump-semver.outputs.new_version }}
- name: Generate new release with changelog
id: release-with-changelog
uses: fregante/[email protected]
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
token: "${{ secrets.GITHUB_TOKEN }}"
exclude: '^chore|^docs|^ci|^build|^refactor|^style|^v?\d+\.\d+\.\d+'
tag: "${{ steps.bump-semver.outputs.new_version }}"
title: "Version ${{ steps.bump-semver.outputs.new_version }}"
commit-template: "- {title} ← {hash}"
skip-on-empty: true
template: |
### Changelog
{commits}
{range}
The new image is available at ${{ env.REGISTRY_PATH }}:${{ steps.bump-semver.outputs.new_version }} :tada:
- name: Comment PR
id: add-comment
uses: actions-ecosystem/action-create-comment@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
body: |
The new version [${{ steps.bump-semver.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.bump-semver.outputs.new_version }}) has been released :tada: