Skip to content

Commit

Permalink
Migrate ci to skaffold (#80)
Browse files Browse the repository at this point in the history
* Migrate CI to skaffold

* Remove test branch from ci

* Remove 'Install werf' stage from CI
  • Loading branch information
alexvarko authored Nov 21, 2024
1 parent 47b8673 commit ab07c57
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 79 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ jobs:
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/[email protected]

- name: Log in to registry
# 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/[email protected]
id: build
with:
command: build --tag ${{ github.sha }}
repository: ghcr.io/${{ github.repository_owner }}

stage-deploy:
name: Deploy on stage
needs: converge
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ jobs:
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/[email protected]

- name: Log in to registry
# 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/[email protected]
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 ab07c57

Please sign in to comment.