From b45ee1419a24fa9930f0d5c574f208d72cde4009 Mon Sep 17 00:00:00 2001 From: John Starich Date: Sat, 31 Jul 2021 22:23:47 -0500 Subject: [PATCH] Switch to GitHub Actions (#14) --- .github/workflows/cd.yml | 25 +++++++++++++++++++++++++ .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ .travis.yml | 33 --------------------------------- Dockerfile | 9 +++------ 4 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..4c5ab18 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,25 @@ +name: CD + +on: + push: + branches: [ master ] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: docker build -t go-wasm . + - name: Publish + run: | + git config --global user.email "" + git config --global user.name "GitHub Pages Deploy" + git checkout --orphan gh-pages + git rm -rf . + out=$(mktemp -d) + docker cp $(docker create --rm go-wasm):/usr/share/nginx/html "$out" + find "$out/html" -mindepth 1 -maxdepth 1 -exec cp -r {} ./ \; # Glob doesn't always pick up hidden files by default + git add . + git commit -am "Deploy to GitHub Pages" + git push --force origin gh-pages diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8f0707a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Lint + run: make lint + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Test + run: make test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4b8f3d9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: go -go: - - 1.16.x - -before_install: - - source ~/.nvm/nvm.sh - - nvm install 14 - -jobs: - include: - - name: Lint - script: make lint - - name: Test - script: make test - - name: Build Docker image - script: make docker - services: - - docker - - name: Release - stage: github-pages - if: branch = master AND type = push - script: - - docker build -t go-wasm . - - docker cp $(docker create --rm go-wasm):/usr/share/nginx/html ./public - services: - - docker - deploy: - provider: pages - fqdn: go-wasm.johnstarich.com - skip_cleanup: true - github_token: $GITHUB_TOKEN - keep_history: false # Wasm binaries and go.tar.gz are quite large - local_dir: ./public diff --git a/Dockerfile b/Dockerfile index f68745f..0cec77e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,7 @@ -FROM node:14-alpine as builder +FROM node:14 as builder -RUN apk add --no-cache \ - bash \ - git \ - go \ - make +RUN apt-get update && \ + apt-get install -y golang WORKDIR /src # Cache go installation first