Skip to content

Commit

Permalink
Update actions workflows for lsw fork
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed Jan 17, 2024
1 parent a6f192d commit 5475563
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/go-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19.3
go-version: '1.20'
- name: Run go test with coverage
run: COVER_PROFILE=coverage.txt make test
- name: Codecov upload
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Check

on:
pull_request: {}

jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.2
args: --timeout=5m

build:
name: Test & Build
runs-on: ubuntu-20.04
steps:
- name: Setup up Go 1.x
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Check out code
uses: actions/checkout@v4

- name: Cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make test

- name: Build
run: make build
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
branches:
- main
- develop
tags:
- v*

env:
REGISTRY: ghcr.io/leaseweb
IMAGE_NAME: capi-cloudstack-controller
TAG: build

jobs:
push:
name: Push images
runs-on: ubuntu-20.04

steps:
- name: Check out code
uses: actions/checkout@v4
# This step is run when the branch is main and no tag is set
- name: Sets env vars for main
run: |
echo "TAG=latest" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')

# This step is run when the branch is develop
- name: Sets env vars for develop
run: |
echo "TAG=develop" >> $GITHUB_ENV
if: github.ref == 'refs/heads/develop'

# This step is run when there is a tag
- name: Sets env vars for tag
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
echo "TAG=${VERSION}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')

- name: Cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build container images
run: make docker-build

- name: Log into registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Push
run: |
docker push ${REGISTRY}/${IMAGE_NAME}:${TAG}
release:
name: Release
runs-on: ubuntu-20.04

# Run only if previous job has succeeded
needs: [push]

# Create a release only for tags v*
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build release manifests
run: make release-manifests

- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: false
draft: true
fail_on_unmatched_files: true
generate_release_notes: true
name: ${{ env.TAG }}
files: |
out/metadata.yaml
out/infrastructure-components.yaml

0 comments on commit 5475563

Please sign in to comment.