-
Notifications
You must be signed in to change notification settings - Fork 113
153 lines (142 loc) · 4.94 KB
/
changesets.yaml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Release
on:
push:
branches: [main]
paths-ignore:
- 'docs/**'
- '**.md'
- '!.changeset/**'
- 'LICENSE'
jobs:
version:
name: Determine version
runs-on: ubuntu-latest
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
version: ${{ steps.check_tag.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node and dependencies
uses: ./.github/actions/install-dependencies
- name: Install dependencies
run: pnpm install
- name: Create PR or Publish release
id: changesets
uses: changesets/action@v1
with:
version: pnpm run ci:version
commit: 'chore: update versions'
title: 'chore: update versions'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Hasura Auth tag
id: check_tag
if: steps.changesets.outputs.hasChangesets == 'false'
run: |
VERSION=$(jq -r .version package.json)
GIT_TAG="v$VERSION"
if [ -z "$(git tag -l | grep $GIT_TAG)" ]; then
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
test:
name: Tests
uses: ./.github/workflows/test.yaml
publish:
name: Publish Docker image
needs:
- test
- version
timeout-minutes: 60
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Preprocess environment
id: preprocess-environment
run: echo "aws_account_id=${{ secrets.AWS_PRODUCTION_ACCOUNT_ID }}" >> $GITHUB_OUTPUT
- name: Add git tag
if: needs.version.outputs.version != ''
run: |
git tag "v${{ needs.version.outputs.version }}"
git push origin --tags
- name: Determine tags
id: tags
run: |
echo "docker_tags<<EOF" >> $GITHUB_OUTPUT
echo "type=sha" >> $GITHUB_OUTPUT
if [ "${{ needs.version.outputs.version }}" != "false" ]; then
GIT_TAG="v${{ needs.version.outputs.version }}"
echo "type=semver,pattern={{version}},value=$GIT_TAG" >> $GITHUB_OUTPUT
echo "type=semver,pattern={{major}}.{{minor}},value=$GIT_TAG" >> $GITHUB_OUTPUT
echo "type=semver,pattern={{major}},value=$GIT_TAG" >> $GITHUB_OUTPUT
fi
echo 'EOF' >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
nhost/hasura-auth
${{ steps.preprocess-environment.outputs.aws_account_id }}.dkr.ecr.eu-central-1.amazonaws.com/hasura-auth
tags: ${{ steps.tags.outputs.docker_tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ steps.preprocess-environment.outputs.aws_account_id }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
- name: Build and publish to Docker Hub and AWS ECR
uses: docker/build-push-action@v3
timeout-minutes: 60
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
push: true
- name: Create GitHub Release
uses: taiki-e/create-gh-release-action@v1
if: needs.version.outputs.version != ''
with:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
ref: refs/tags/${{ needs.version.outputs.version }}
- name: Remove tag
if: failure() && needs.version.outputs.version != ''
run: git push --delete origin ${{ needs.version.outputs.version }}
release:
name: GitHub release
needs: publish
runs-on: ubuntu-latest
if: needs.publish.needs.version.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create GitHub Release
uses: taiki-e/create-gh-release-action@v1
if: needs.version.outputs.version != ''
with:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
ref: refs/tags/${{ needs.version.outputs.version }}