Skip to content

Commit 73bc9c6

Browse files
author
Andres Pinto
committed
Merge branch 'master' into feat/uncomment-limits-and-seeder-for-sharings
2 parents e03a750 + 6ea4614 commit 73bc9c6

5 files changed

Lines changed: 235 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build & Publish Stable Preview
2+
on:
3+
push:
4+
branches: ["master"]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check Out Repo
10+
uses: actions/checkout@v2
11+
with:
12+
registry-url: 'https://npm.pkg.github.com'
13+
- run: echo "registry=https://registry.yarnpkg.com/" > .npmrc
14+
- run: echo "@internxt:registry=https://npm.pkg.github.com" >> .npmrc
15+
# You cannot read packages from other private repos with GITHUB_TOKEN
16+
# You have to use a PAT instead https://github.com/actions/setup-node/issues/49
17+
- run: echo //npm.pkg.github.com/:_authToken=${{ secrets.PERSONAL_ACCESS_TOKEN }} >> .npmrc
18+
- run: echo "always-auth=true" >> .npmrc
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v1
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
- name: Build and push to ${{ github.event.repository.name }}-dev
27+
uses: docker/build-push-action@v2
28+
with:
29+
context: ./
30+
file: ./infrastructure/preview.Dockerfile
31+
push: true
32+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}-dev:${{ github.sha }}
33+
dispatch_update_preview_image:
34+
needs: build
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Dispatch Update Preview Image Command
38+
uses: myrotvorets/trigger-repository-dispatch-action@1.0.0
39+
with:
40+
token: ${{ secrets.PAT }}
41+
repo: internxt/environments
42+
type: update-preview-image-command
43+
payload: |
44+
{
45+
"image": {
46+
"name": "${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}",
47+
"newName": "${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}-dev",
48+
"newTag": "${{ github.sha }}"
49+
}
50+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Deploy PR Preview
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize, ready_for_review]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check Out Repo
10+
uses: actions/checkout@v2
11+
with:
12+
registry-url: 'https://npm.pkg.github.com'
13+
- run: echo "registry=https://registry.yarnpkg.com/" > .npmrc
14+
- run: echo "@internxt:registry=https://npm.pkg.github.com" >> .npmrc
15+
# You cannot read packages from other private repos with GITHUB_TOKEN
16+
# You have to use a PAT instead https://github.com/actions/setup-node/issues/49
17+
- run: echo //npm.pkg.github.com/:_authToken=${{ secrets.PERSONAL_ACCESS_TOKEN }} >> .npmrc
18+
- run: echo "always-auth=true" >> .npmrc
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v1
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
- name: Build and push to ${{ github.event.repository.name}}-dev
27+
uses: docker/build-push-action@v2
28+
with:
29+
context: ./
30+
file: ./infrastructure/preview.Dockerfile
31+
push: true
32+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}-dev:preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}
33+
add_ready_for_preview_label:
34+
if: github.event.pull_request.draft == false
35+
runs-on: ubuntu-latest
36+
needs: build
37+
steps:
38+
- uses: actions-ecosystem/action-add-labels@v1
39+
with:
40+
labels: |
41+
ready-for-preview
42+
dispatch_update_deployment:
43+
needs: add_ready_for_preview_label
44+
runs-on: ubuntu-latest
45+
if: ${{ contains(github.event.pull_request.labels.*.name, 'deployed') }}
46+
steps:
47+
- name: Dispatch Update Preview Repository Command
48+
uses: myrotvorets/trigger-repository-dispatch-action@1.0.0
49+
with:
50+
token: ${{ secrets.PAT }}
51+
repo: internxt/environments
52+
type: update-preview-command
53+
payload: |
54+
{
55+
"github": {
56+
"payload": {
57+
"repository": {
58+
"name": "${{ github.event.repository.name }}",
59+
"full_name": "${{ github.event.repository.full_name }}"
60+
},
61+
"issue": {
62+
"number": ${{ github.event.number }},
63+
"labels": ${{ toJSON(github.event.pull_request.labels) }}
64+
}
65+
}
66+
},
67+
"slash_command": {
68+
"args": {
69+
"named": {
70+
"deployment": "${{ github.event.repository.name }}",
71+
"tag": "preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}",
72+
"imageSuffix": "-dev"
73+
}
74+
}
75+
}
76+
}
77+
dispatch_check_deployment:
78+
needs: add_ready_for_preview_label
79+
runs-on: ubuntu-latest
80+
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview') }}
81+
steps:
82+
- name: Dispatch Check Preview Repository Command
83+
uses: myrotvorets/trigger-repository-dispatch-action@1.0.0
84+
with:
85+
token: ${{ secrets.PAT }}
86+
repo: internxt/environments
87+
type: check-preview-command
88+
payload: |
89+
{
90+
"github": {
91+
"payload": {
92+
"repository": {
93+
"name": "${{ github.event.repository.name }}",
94+
"full_name": "${{ github.event.repository.full_name }}",
95+
"html_url": "${{ github.event.repository.html_url }}"
96+
},
97+
"issue": {
98+
"number": ${{ github.event.number }},
99+
"labels": ${{ toJSON(github.event.pull_request.labels) }},
100+
"pull_request": {
101+
"html_url": "${{ github.event.pull_request.html_url }}"
102+
}
103+
}
104+
}
105+
},
106+
"slash_command": {
107+
"args": {
108+
"named": {
109+
"notify": "true"
110+
}
111+
}
112+
}
113+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Clean Up PR Preview
2+
on:
3+
pull_request:
4+
types: [closed]
5+
jobs:
6+
dispatch_cleanup_deployment:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Dispatch Cleanup Preview Repository Command
10+
uses: myrotvorets/trigger-repository-dispatch-action@1.0.0
11+
with:
12+
token: ${{ secrets.PAT }}
13+
repo: internxt/environments
14+
type: cleanup-preview-command
15+
payload: |
16+
{
17+
"github": {
18+
"payload": {
19+
"repository": {
20+
"name": "${{ github.event.repository.name }}"
21+
},
22+
"issue": {
23+
"number": ${{ github.event.number }}
24+
}
25+
}
26+
}
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Slash Command Dispatch
2+
on:
3+
issue_comment:
4+
types: [created]
5+
jobs:
6+
slash_command_dispatch:
7+
runs-on: ubuntu-latest
8+
if: ${{ contains(github.event.issue.labels.*.name, 'deployed') || contains(github.event.issue.labels.*.name, 'preview') }}
9+
steps:
10+
- name: Slash Command Dispatch
11+
id: scd
12+
uses: peter-evans/slash-command-dispatch@v4
13+
with:
14+
token: ${{ secrets.PAT }}
15+
commands: update-preview,check-preview
16+
permission: write
17+
repository: internxt/environments
18+
issue-type: pull-request
19+
allow-edits: false
20+
reactions: false
21+
- name: Edit comment with error message
22+
if: steps.scd.outputs.error-message
23+
uses: peter-evans/create-or-update-comment@v4
24+
with:
25+
comment-id: ${{ github.event.comment.id }}
26+
body: |
27+
28+
> [!CAUTION]
29+
> Couldn't dispatch your command due to error:
30+
> **${{ steps.scd.outputs.error-message }}**
31+

infrastructure/preview.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:20.10-alpine
2+
3+
WORKDIR /usr/app
4+
5+
COPY package.json ./
6+
COPY yarn.lock ./
7+
COPY .npmrc ./
8+
9+
RUN yarn
10+
COPY . ./
11+
12+
RUN yarn build
13+
14+
CMD yarn migrate && yarn db:seed:test:all && yarn start:dev

0 commit comments

Comments
 (0)