-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (82 loc) · 2.76 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: "Release"
on:
push:
branches:
- main
paths-ignore:
- "README.md"
- "catalog.yaml"
workflow_dispatch:
inputs:
gratibot_limit:
description: "The amount of fistbumps that a user can give for one day."
required: false
default: "5"
type: string
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gratibot
IMAGE_PATH: ${{ github.repository_owner }}/gratibot
permissions:
id-token: write
contents: write
packages: write
jobs:
build:
name: Build and Publish Image
if: github.event_name == 'push' || contains(fromJSON('["Pactionly", "gesparza3"]'), github.actor)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate tag
id: tag
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME:${{ steps.tag.outputs.sha_short }} --label "runnumber=${GITHUB_RUN_ID}"
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: docker push $IMAGE_NAME:${{ steps.tag.outputs.sha_short }}
outputs:
docker_tag: ${{ steps.tag.outputs.sha_short }}
apply:
name: "Terraform Apply"
runs-on: ubuntu-latest
environment:
name: "nonprod"
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terragrunt
run: |
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.45.11/terragrunt_linux_amd64
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
- name: Deploy Gratibot to Nonprod
working-directory: infra/terragrunt/nonprod/gratibot/
run: |
terragrunt apply --terragrunt-non-interactive -auto-approve
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_NONPROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_limit: ${{ inputs.gratibot_limit }}
release:
name: "Create Release"
runs-on: ubuntu-latest
needs: apply
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install devDependencies
run: npm install
- name: Create Release
run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GRATIBOT_RELEASE_TOKEN }}