Skip to content

Commit

Permalink
run tests in container
Browse files Browse the repository at this point in the history
  • Loading branch information
cromega committed Apr 3, 2021
1 parent 48c6415 commit a57c2fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,29 @@ on:
branches: [ master ]

jobs:
test:
release:
runs-on: ubuntu-latest
container: golang:1.16.3-alpine3.13
steps:
- name: Check out
uses: actions/checkout@v2

- name: Prepare container
run: |
apk add --no-cache openssh-keygen
chmod 600 testdata/real_id_rsa
- name: Test
run: |
export CGO_ENABLED=0
go test -v
docker build --target builder -t base .
docker run --rm base go test -v
push:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Docker login
- name: Build final image
run: docker build -t cromega/keyguard .

- name: Docker push
env:
DOCKERHUB_PW: ${{ secrets.dockerhub_password }}
run: echo "$DOCKERHUB_PW" | docker login -u cromega --password-stdin

- name: Build
run: docker build -t cromega/keyguard .
- name: Push
run: docker push cromega/keyguard
run: |
echo "$DOCKERHUB_PW" | docker login -u cromega --password-stdin
docker push cromega/keyguard
trigger-deploy:
needs: [push]
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Trigger deployment
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ FROM golang:1.16.3-alpine3.13 AS builder
ADD . /build
WORKDIR /build

RUN apk add --no-cache openssh-keygen && chmod 600 testdata/*

ENV CGO_ENABLED=0
RUN go version && go build -mod=vendor


FROM alpine:latest

RUN apk add --no-cache openssh-keygen && \
Expand Down

0 comments on commit a57c2fc

Please sign in to comment.