mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +00:00
start redoing ci/cd and devops
This commit is contained in:
parent
460770407a
commit
ab9fe30b42
37 changed files with 418 additions and 825 deletions
126
.github/workflows/build.yml
vendored
126
.github/workflows/build.yml
vendored
|
@ -3,61 +3,87 @@ name: Bazel Build
|
|||
on: push
|
||||
|
||||
jobs:
|
||||
bazel_build:
|
||||
name: Bazel Build
|
||||
go_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Go CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.15.5'
|
||||
|
||||
- run: go vet ./...
|
||||
|
||||
- run: go test ./...
|
||||
|
||||
node_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Mount bazel cache
|
||||
uses: actions/cache@v2.1.2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
with:
|
||||
path: |
|
||||
/home/runner/.cache/bazel
|
||||
/home/runner/.cache/bazel-disk-cache
|
||||
key: bazel
|
||||
node-version: '14'
|
||||
|
||||
- name: Install bazelisk
|
||||
run: |
|
||||
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
|
||||
mkdir -p "${GITHUB_WORKSPACE}/bin/"
|
||||
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
|
||||
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
"${GITHUB_WORKSPACE}/bin/bazel" test \
|
||||
-k -c opt \
|
||||
--stamp \
|
||||
--workspace_status_command hack/workspace_status.sh --\
|
||||
//src/... //hack/... -//hack/dev-container/...
|
||||
|
||||
- name: Docker Login
|
||||
run: |
|
||||
echo ${{github.token}} | docker login -u ${{github.actor}} --password-stdin docker.pkg.github.com
|
||||
|
||||
- name: Publish Artifacts
|
||||
run: |
|
||||
"${GITHUB_WORKSPACE}/bin/bazel" query //src/... |\
|
||||
grep +publish |\
|
||||
xargs -l1 "${GITHUB_WORKSPACE}/bin/bazel" run \
|
||||
-c opt \
|
||||
--stamp \
|
||||
--workspace_status_command hack/workspace_status.sh
|
||||
|
||||
- name: Write Artifact Manifest
|
||||
run: |
|
||||
artifacts=$(${GITHUB_WORKSPACE}/bin/bazel query //src/... | grep +publish)
|
||||
publishedServices=${artifacts//$'//src/'/}
|
||||
publishedServices=${publishedServices//$':+publish'/}
|
||||
manifestJSON='{"services": {}}'
|
||||
for svc in $publishedServices; do
|
||||
manifestJSON=$(echo $manifestJSON | jq ".services+={\"$svc\":\"$(cat bazel-bin/src/$svc/+publish.digest)\"}")
|
||||
done
|
||||
echo $manifestJSON > manifest.json
|
||||
|
||||
- name: Upload Artifact Manifest
|
||||
uses: actions/upload-artifact@v2
|
||||
- uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
name: manifest.json
|
||||
path: manifest.json
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
- run: yarn lint
|
||||
|
||||
- run: yarn test
|
||||
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
with:
|
||||
images: docker.pkg.github.com/roleypoly/roleypoly/ui
|
||||
tag-sha: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Login to GitHub Packages Docker Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: docker.pkg.github.com
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: .hack/dockerfiles/ui.Dockerfile
|
||||
push: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue