Skip to content

Commit

Permalink
Draft CI and lint workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
themoriarti committed Apr 25, 2024
1 parent ca79f72 commit ba4f794
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI/CD Workflow

on:
push:
branches:
- main
paths:
- '**.yaml'
- '**/Dockerfile'
- '**/charts/**'
tags:
- 'v*'
pull_request: {}

env:
IMAGE_NGINX_CACHE: nginx-cache
#REGISTRY: ghcr.io/${{ github.repository_owner }}
PUSH: 1
LOAD: 1
NGINX_CACHE_TAG: v0.1.0
TAG: v0.3.1
PLATFORM_ARCH: linux/amd64

jobs:
build-and-push:
name: Build Cozystack
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Set up Docker Registry
run: |
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "REGISTRY=ghcr.io/${{ github.repository_owner }}" >> $GITHUB_ENV
else
echo "REGISTRY=localhost:5000/cozystack_local" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- name: Build Docker image
run: |
cd packages/apps/http-cache
docker buildx build --platform ${PLATFORM_ARCH} --build-arg ARCH=amd64 images/${IMAGE_NGINX_CACHE} --provenance false \
--tag ${REGISTRY}/${IMAGE_NGINX_CACHE}:${NGINX_CACHE_TAG} \
--tag ${REGISTRY}/${IMAGE_NGINX_CACHE}:${NGINX_CACHE_TAG}-${TAG} \
--cache-from type=registry,ref=${REGISTRY}/${IMAGE_NGINX_CACHE}:${NGINX_CACHE_TAG} \
--cache-to type=inline --metadata-file images/nginx-cache.json --push=${PUSH} --load=${LOAD}
echo "${REGISTRY}/${IMAGE_NGINX_CACHE}:${NGINX_CACHE_TAG}" > images/nginx-cache.tag
docker tag $REGISTRY/${IMAGE_NGINX_CACHE}:${{ github.sha }} $REGISTRY/$IMAGE_NAME:latest
- name: Log in to Docker Registry
run: echo ${{ secrets.REGISTRY_PASSWORD }} | docker login $DOCKER_REGISTRY --username ${{ secrets.REGISTRY_USERNAME }} --password-stdin

- name: Push Docker images
run: |
docker push $REGISTRY/${IMAGE_NGINX_CACHE}:${{ github.sha }}
docker push $REGISTRY/${IMAGE_NGINX_CACHE}:latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

deploy:
needs: build-and-push
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Configure kubectl
uses: azure/setup-kubectl@v2
- name: Set up Helm
uses: azure/setup-helm@v2
- name: Add Helm repo
run: helm repo add myrepo https://example.com/helm
- name: Deploy Helm chart
run: |
helm upgrade --install myrelease myrepo/mychart --namespace default --set image.tag=${{ github.sha }}
34 changes: 34 additions & 0 deletions .github/workflows/config/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

rules:
anchors: enable
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
level: warning
comments-indentation:
level: warning
document-end: disable
document-start:
level: warning
empty-lines: enable
empty-values: disable
float-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
line-length: enable
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
44 changes: 44 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint

on: # yamllint disable-line rule:truthy
push: null
pull_request: null

permissions: {}

env:
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
FILTER_REGEX_EXCLUDE: \.git/.*

jobs:
build:
name: Lint
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0

- name: Super-linter
uses: super-linter/super-linter/slim@latest # x-release-please-version
env:
LINTER_RULES_PATH: '.'
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_ES: false
VALIDATE_PYTHON_BLACK: false
VALIDATE_HTML: false
VALIDATE_GO: false
VALIDATE_XML: false
VALIDATE_JAVA: false
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ba4f794

Please sign in to comment.