Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #267 from vania-pooh/master
Browse files Browse the repository at this point in the history
Migrated to Github Actions (fixes #265)
  • Loading branch information
vania-pooh authored Jul 7, 2020
2 parents cecc98d + 9d1f9a3 commit 8b7a47e
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 74 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build

on:
push:
branches:
- master

jobs:
golang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: ci/test.sh

- name: Build
run: ci/build.sh

- name: Latest image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ci/docker-push.sh latest

- name: Latest docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ci/docs.sh latest ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: build

on:
release:
types: [published]

jobs:
golang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: ci/test.sh

- name: Build
run: ci/build.sh

- name: Prepare release version
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}

- uses: AButler/[email protected]
with:
files: 'dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Release image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ci/docker-push.sh $RELEASE_VERSION

- name: Latest release image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ci/docker-push.sh latest-release

- name: Latest docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ci/docs.sh $RELEASE_VERSION ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: test

on:
pull_request:

jobs:
golang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.14.x

- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: ci/test.sh

- name: Build
run: ci/build.sh

- uses: codecov/codecov-action@v1
with:
flags: go
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

export GO111MODULE="on"
go get -u github.com/mitchellh/gox # cross compile
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git describe --tags || git rev-parse HEAD` -s -w"
gox -os "linux darwin windows" -arch "amd64" -osarch="windows/386" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git describe --tags || git rev-parse HEAD` -s -w"
9 changes: 9 additions & 0 deletions ci/docker-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

docker build -t $GITHUB_REPOSITORY .
docker tag $GITHUB_REPOSITORY $GITHUB_REPOSITORY:$1
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker push $GITHUB_REPOSITORY
docker push $GITHUB_REPOSITORY:$1
22 changes: 11 additions & 11 deletions travis/docs.sh → ci/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@
set -e
TAGNAME=$1
GH_REF=github.com/aerokube/cm.git
git config user.name "${TRAVIS_REPO_SLUG}"
git config user.name "${GITHUB_REPOSITORY}"
git config user.email "[email protected]"
git remote add upstream "https://${GITHUB_TOKEN}@${GH_REF}"
git fetch upstream

git branch -r

echo "Deleting old output"
rm -rf ${TRAVIS_BUILD_DIR}/docs/output
mkdir ${TRAVIS_BUILD_DIR}/docs/output
rm -rf ${GITHUB_WORKSPACE}/docs/output
mkdir ${GITHUB_WORKSPACE}/docs/output
git worktree prune
rm -rf ${TRAVIS_BUILD_DIR}/.git/worktrees/docs/output/
rm -rf ${GITHUB_WORKSPACE}/.git/worktrees/docs/output/

echo "Checking out gh-pages branch into docs/output"
git worktree add -B gh-pages ${TRAVIS_BUILD_DIR}/docs/output upstream/gh-pages
git worktree add -B gh-pages ${GITHUB_WORKSPACE}/docs/output upstream/gh-pages

echo "Removing existing files"
mkdir -p ${TRAVIS_BUILD_DIR}/docs/output/${TAGNAME}
rm -rf ${TRAVIS_BUILD_DIR}/docs/output/${TAGNAME}/*
mkdir -p ${GITHUB_WORKSPACE}/docs/output/${TAGNAME}
rm -rf ${GITHUB_WORKSPACE}/docs/output/${TAGNAME}/*

echo "Copying images"
cp -R ${TRAVIS_BUILD_DIR}/docs/img ${TRAVIS_BUILD_DIR}/docs/output/${TAGNAME}/img
cp -R ${GITHUB_WORKSPACE}/docs/img ${GITHUB_WORKSPACE}/docs/output/${TAGNAME}/img
echo "Copying files to root"
cp -Rv ${TRAVIS_BUILD_DIR}/docs/files/* ${TRAVIS_BUILD_DIR}/docs/output
cp -Rv ${GITHUB_WORKSPACE}/docs/files/* ${GITHUB_WORKSPACE}/docs/output

echo "Generating docs"
docker run -v ${TRAVIS_BUILD_DIR}/docs/:/documents/ --name asciidoc-to-html asciidoctor/docker-asciidoctor asciidoctor -a revnumber=${TAGNAME} -D /documents/output/${TAGNAME} index.adoc
docker run -v ${GITHUB_WORKSPACE}/docs/:/documents/ --name asciidoc-to-html asciidoctor/docker-asciidoctor asciidoctor -a revnumber=${TAGNAME} -D /documents/output/${TAGNAME} index.adoc


echo "Updating gh-pages branch"
cd ${TRAVIS_BUILD_DIR}/docs/output && git add --all && git status && git commit -m "Publishing to gh-pages"
cd ${GITHUB_WORKSPACE}/docs/output && git add --all && git status && git commit -m "Publishing to gh-pages"


git push upstream HEAD:gh-pages
4 changes: 4 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export GO111MODULE="on"
go test -race -v github.com/aerokube/cm/selenoid -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/aerokube/cm/selenoid
9 changes: 0 additions & 9 deletions travis/docker-push.sh

This file was deleted.

0 comments on commit 8b7a47e

Please sign in to comment.