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 60ad0d7 commit 8869279
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 58 deletions.
29 changes: 17 additions & 12 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 @@ -14,24 +15,28 @@ jobs:
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/install@v1.2

- 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/github-action-skaffold@latest
id: build
with:
command: build --tag ${{ github.sha }}
repository: ghcr.io/${{ github.repository_owner }}

stage-deploy:
name: Deploy on stage
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
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:16-alpine AS builder

WORKDIR /app

COPY package.json package-lock.json ./
COPY .env.deploy .env

RUN npm install

COPY . .

RUN npm run build

FROM nginx:alpine AS web

COPY nginx.conf /etc/nginx/nginx.conf

COPY --from=builder /app/build /usr/share/nginx/html

# Expose port 80
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
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: docs
37 changes: 0 additions & 37 deletions werf.yaml

This file was deleted.

0 comments on commit 8869279

Please sign in to comment.