-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding workflow to create dev/prod images (#38)
* adding workflow to create dev/prod images * test * test * fix naming * return data after test * fix build * test run * fix build * return data from testing back * update images * trigger workflow * add secrets to build image * update to build args * fix envs * update build workflow * test * update path * fix version * update image version * return if condition back * update workflow * change build file
- Loading branch information
Showing
10 changed files
with
246 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: 'Deploy Image Composite Action' | ||
description: 'Composite action to deploy image' | ||
inputs: | ||
HOST: | ||
description: 'SSH Host' | ||
required: true | ||
USERNAME: | ||
description: 'SSH Username' | ||
required: true | ||
KEY: | ||
description: 'SSH Key' | ||
required: true | ||
PORT: | ||
description: 'SSH Port' | ||
required: true | ||
PAT_FOR_DOCKER_REGISTRY: | ||
description: 'PAT for Docker Registry' | ||
required: true | ||
TELEGRAM_TO: | ||
description: 'Telegram To' | ||
required: true | ||
TELEGRAM_TOKEN: | ||
description: 'Telegram Token' | ||
required: true | ||
DEPLOYED_BOT: | ||
description: 'Which bot was updated' | ||
required: true | ||
IMAGE_TO_DEPLOY: | ||
description: 'Which bot was updated' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: executing remote ssh commands using ssh key | ||
uses: appleboy/ssh-action@v1.0.0 | ||
with: | ||
host: ${{ inputs.HOST }} | ||
username: ${{ inputs.USERNAME }} | ||
key: ${{ inputs.KEY }} | ||
port: ${{ inputs.PORT }} | ||
script: | | ||
cd ./nova-wallet-web-app | ||
echo ${{ inputs.PAT_FOR_DOCKER_REGISTRY }} | docker login ghcr.io -u stepanLav --password-stdin | ||
docker-compose down | ||
docker-compose pull | ||
docker-compose up -d | ||
docker image prune -f | ||
- name: Notify Telegram channel | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ inputs.TELEGRAM_TO }} | ||
token: ${{ inputs.TELEGRAM_TOKEN }} | ||
format: markdown | ||
message: | | ||
🖥️ New version for bot web app was deployed! | ||
version: ${{ inputs.IMAGE_TO_DEPLOY }} | ||
commit: ${{ github.sha }} | ||
updated_bot: @${{ inputs.DEPLOYED_BOT }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Build image | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'dev' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
- 'dev' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-docker: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
docker_tags: ${{ steps.meta.outputs.tags }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
file: ./docker/Dockerfile | ||
build-args: | | ||
NEXT_PUBLIC_BOT_API_URL=${{ secrets.NEXT_PUBLIC_BOT_API_URL }} | ||
NEXT_PUBLIC_BOT_ADDRESS=${{ secrets.NEXT_PUBLIC_BOT_ADDRESS }} | ||
NEXT_PUBLIC_WEB_APP_ADDRESS=${{ secrets.NEXT_PUBLIC_WEB_APP_ADDRESS }} | ||
deploy-dev: | ||
runs-on: ubuntu-latest | ||
needs: build-docker | ||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Deploy Image | ||
uses: ./.github/actions/deploy | ||
with: | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
KEY: ${{ secrets.KEY }} | ||
PORT: ${{ secrets.PORT }} | ||
PAT_FOR_DOCKER_REGISTRY: ${{ secrets.PAT_FOR_DOCKER_REGISTRY }} | ||
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} | ||
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | ||
DEPLOYED_BOT: ${{ secrets.NEXT_PUBLIC_BOT_ADDRESS }} | ||
IMAGE_TO_DEPLOY: ${{ needs.build-docker.outputs.docker_tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Create tag on Push to Main | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.CREATE_TAG_PAT }} | ||
|
||
- name: 'Get Previous tag' | ||
id: previoustag | ||
uses: WyriHaximus/github-action-get-previous-tag@v1 | ||
|
||
- name: Read package.json | ||
run: | | ||
echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV | ||
- name: Put text version to env | ||
run: | | ||
echo "${{ fromJson(env.PACKAGE_JSON).version }}" | ||
echo "PACKAGE_VERSION=${{ format('{0}{1}', 'v', fromJson(env.PACKAGE_JSON).version) }}" >> $GITHUB_ENV | ||
- name: Create new tag | ||
if: ${{ steps.previoustag.outputs.tag != env.PACKAGE_VERSION }} | ||
uses: rickstaa/action-create-tag@v1.7.2 | ||
with: | ||
tag: v${{ fromJson(env.PACKAGE_JSON).version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Check Package.json Version | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout base branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Get version from base branch | ||
id: base_version | ||
run: echo "MAIN_VERSION=$(jq -c . < package.json)" >> $GITHUB_ENV | ||
|
||
- name: Checkout PR branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Get version from PR branch | ||
id: pr_version | ||
run: echo "PR_VERSION=$(jq -c . < package.json)" >> $GITHUB_ENV | ||
|
||
- name: Compare versions | ||
run: | | ||
if [ "${{ env.PR_VERSION }}" == "${{ env.MAIN_VERSION }}" ]; then | ||
echo "Version in package.json has not been updated." | ||
exit 1 | ||
else | ||
echo "Version in package.json has been updated." | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
version: '3' | ||
services: | ||
app: | ||
build: . | ||
build: ./docker/Dockerfile | ||
ports: | ||
- 3000:3000 | ||
volumes: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Dockerfile.build | ||
FROM node:18-alpine AS build | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
ARG NEXT_PUBLIC_BOT_API_URL | ||
ARG NEXT_PUBLIC_BOT_ADDRESS | ||
ARG NEXT_PUBLIC_WEB_APP_ADDRESS | ||
ENV NEXT_PUBLIC_BOT_API_URL=$NEXT_PUBLIC_BOT_API_URL | ||
ENV NEXT_PUBLIC_BOT_ADDRESS=$NEXT_PUBLIC_BOT_ADDRESS | ||
ENV NEXT_PUBLIC_WEB_APP_ADDRESS=$NEXT_PUBLIC_WEB_APP_ADDRESS | ||
|
||
RUN yarn install | ||
RUN yarn build | ||
|
||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app/.next ./.next | ||
COPY --from=build /app/public ./public | ||
COPY package.json ./ | ||
COPY yarn.lock ./ | ||
|
||
RUN yarn install | ||
|
||
CMD ["yarn", "start"] |
Oops, something went wrong.