Skip to content

Commit

Permalink
Migrate CI to skaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvarko committed Nov 21, 2024
1 parent 47b8673 commit 31c3f9c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 73 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- 'master'
- 'feature/migrate-ci-to-skaffold'

jobs:
converge:
Expand All @@ -21,17 +22,25 @@ jobs:
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_SHA
- name: Run Build
- name: Cache layers
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/.skaffold/cache"
key: skaffold-${{ hashFiles('**/cache') }}
restore-keys: |
skaffold-
- name: Set up environment variables
run: |
. $(werf ci-env github --as-file)
echo "${{ secrets.STAGE_ENV }}" > .env.deploy
werf export web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA --dev
- name: Run Skaffold pipeline as command
uses: hiberbee/github-action-skaffold@latest
id: build
with:
command: build --tag ${{ github.sha }}
repository: ghcr.io/${{ github.repository_owner }}

stage-deploy:
name: Deploy on stage
needs: converge
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@ jobs:
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_REF_NAME
- name: Run Build
- name: Cache layers
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/.skaffold/cache"
key: skaffold-${{ hashFiles('**/cache') }}
restore-keys: |
skaffold-
- name: Set up environment variables
run: |
. $(werf ci-env github --as-file)
echo "${{ secrets.PROD_ENV }}" > .env.deploy
werf export web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME --dev
- name: Run Skaffold pipeline as command
uses: hiberbee/github-action-skaffold@latest
id: build
with:
command: build --tag ${{ github.ref_name }}
repository: ghcr.io/${{ github.repository_owner }}

prod-deploy:
name: Deploy on prod
needs: converge
Expand Down
35 changes: 16 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
FROM node:14-alpine3.11 as builder
RUN apk --no-cache --update --virtual build-dependencies add \
python \
make \
g++

ARG BUILD_VERSION
WORKDIR /dist
COPY package*.json ./
COPY yarn*.lock ./
RUN true \
&& yarn autoclean --init \
&& yarn autoclean --force \
&& yarn install \
&& true
FROM node:18-alpine AS builder

RUN apk --no-cache --update --virtual build-dependencies add python3 make g++

WORKDIR /frontend

COPY package.json yarn.lock ./

RUN yarn install

COPY . .
RUN yarn lint | tee 1.log | sed -e 's/^/[yarn lint] /' & yarn test | tee 2.log | sed -e 's/^/[yarn test] /' & yarn build --set-build-version "$BUILD_VERSION" | tee 3.log | sed -e 's/^/[yarn build] /'

FROM nginx:1.20.2-alpine
RUN yarn generate --dotenv .env.deploy

FROM nginx:alpine

COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /build/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]

COPY --from=builder /frontend/.output/public /usr/share/nginx/html
5 changes: 5 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: skaffold/v2beta28
kind: Config
build:
artifacts:
- image: frontend
36 changes: 0 additions & 36 deletions werf.yaml

This file was deleted.

0 comments on commit 31c3f9c

Please sign in to comment.