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 1c099c0 commit 35b3d2e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 73 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- 'master'
# - '**'
- '**'

env:
CI_JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -26,16 +26,20 @@ 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
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
- name: Cache layers
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/.skaffold/cache"
key: skaffold-${{ hashFiles('**/cache') }}
restore-keys: |
skaffold-
- 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
24 changes: 14 additions & 10 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ 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
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME
- name: Cache layers
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/.skaffold/cache"
key: skaffold-${{ hashFiles('**/cache') }}
restore-keys: |
skaffold-
- 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
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
FROM golang:1.20-alpine as buildbase

RUN apk add git build-base
ARG CI_JOB_TOKEN

RUN apk add git build-base ca-certificates
WORKDIR /go/src/github.com/dl-solarity/frontend-link-shortener-svc
COPY vendor .
COPY . .

RUN GOOS=linux go build -o /usr/local/bin/frontend-link-shortener-svc /go/src/github.com/dl-solarity/frontend-link-shortener-svc
RUN git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com".insteadOf https://gitlab.com
RUN git config --global url."https://${CI_JOB_TOKEN}@github.com/".insteadOf https://github.com/
RUN go env -w GOPRIVATE=github.com/*,gitlab.com/*

RUN go mod tidy && go mod vendor
RUN CGO_ENABLED=1 GO111MODULE=on GOOS=linux go build -o /usr/local/bin/frontend-link-shortener /go/src/github.com/dl-solarity/frontend-link-shortener-svc

FROM alpine:3.9
FROM scratch
COPY --from=alpine:3.9 /bin/sh /bin/sh
COPY --from=alpine:3.9 /usr /usr
COPY --from=alpine:3.9 /lib /lib

COPY --from=buildbase /usr/local/bin/frontend-link-shortener-svc /usr/local/bin/frontend-link-shortener-svc
RUN apk add --no-cache ca-certificates
COPY --from=buildbase /usr/local/bin/frontend-link-shortener /usr/local/bin/frontend-link-shortener
COPY --from=buildbase /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["frontend-link-shortener-svc"]
ENTRYPOINT ["frontend-link-shortener"]
8 changes: 8 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: skaffold/v2beta28
kind: Config
build:
artifacts:
- image: frontend-link-shortener-svc
docker:
buildArgs:
CI_JOB_TOKEN: "{{.CI_JOB_TOKEN}}"
45 changes: 0 additions & 45 deletions werf.yaml

This file was deleted.

0 comments on commit 35b3d2e

Please sign in to comment.