Skip to content

Commit

Permalink
Merge pull request #67 from SmartCityFlensburg/release/v1.0.0
Browse files Browse the repository at this point in the history
Release version v1.0.0
  • Loading branch information
choffmann authored Jul 6, 2024
2 parents c6272f6 + 79df8f6 commit 9b0a611
Show file tree
Hide file tree
Showing 120 changed files with 3,285 additions and 749 deletions.
2 changes: 2 additions & 0 deletions .docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RUN yarn build:dev


FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/dist /usr/share/nginx/html

EXPOSE 80
Expand Down
2 changes: 2 additions & 0 deletions .docker/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RUN yarn build


FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/dist /usr/share/nginx/html

EXPOSE 80
Expand Down
2 changes: 2 additions & 0 deletions .docker/Dockerfile.stage
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RUN yarn build:stage


FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/dist /usr/share/nginx/html

EXPOSE 80
Expand Down
9 changes: 9 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;
listen [::]:80;

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
}
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# EditorConfig is awesome: https://EditorConfig.org

# Top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.css]
indent_size = 4

[*.scss]
indent_size = 4

[*.js]
indent_size = 4

[*.json]
indent_size = 2

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2
36 changes: 34 additions & 2 deletions .github/workflows/build-and-push-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ jobs:
build_and_deploy_dev:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set commit sha
run: |
echo "COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -41,4 +45,32 @@ jobs:
file: ./.docker/Dockerfile.dev
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-dev:latest
tags: ghcr.io/${{ env.REPO_LC }}-dev:latest, ghcr.io/${{ env.REPO_LC }}-dev:${{ env.COMMIT_SHA }}

- name: "Setup yq"
uses: dcarbone/[email protected]
with:
version: "v4.42.1"
force: true

- name: Initialize mandatory git config
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Bump version in values/develop.yaml
run: yq -i '.deployment.image.tag=strenv(COMMIT_SHA)' ./k8s/values/develop.yaml

- name: Commit k8s values files
id: make-commit
run: |
git add ./k8s/values/develop.yaml
git commit --message "Update dev image to commit ${{ env.COMMIT_SHA }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push changes
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: develop
76 changes: 73 additions & 3 deletions .github/workflows/build-and-push-stage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build and Push Docker Image Staging
"on":
workflow_dispatch:
push:
branches:
- release/*
Expand All @@ -9,7 +10,7 @@ jobs:
build_and_deploy_stage:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write
actions: write
steps:
Expand Down Expand Up @@ -37,6 +38,11 @@ jobs:
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from input (for manual workflow dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -56,11 +62,75 @@ jobs:
env:
REPO: "${{ github.repository }}"

- name: Build and push
- name: Set commit sha
run: |
echo "COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Build and push Version
if: github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: .
file: ./.docker/Dockerfile.stage
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-stage:${{ env.RELEASE_VERSION }}-preview, ghcr.io/${{ env.REPO_LC }}-stage:latest, ghcr.io/${{ env.REPO_LC }}-stage:${{ env.COMMIT_SHA }}

- name: Build and push Version
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v5
with:
context: .
file: ./.docker/Dockerfile.stage
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-stage:${{ env.RELEASE_VERSION }}-preview, ghcr.io/${{ env.REPO_LC }}-stage:lastest
tags: ghcr.io/${{ env.REPO_LC }}-stage:latest, ghcr.io/${{ env.REPO_LC }}-stage:${{ env.COMMIT_SHA }}

- name: "Setup yq"
uses: dcarbone/[email protected]
with:
version: "v4.42.1"
force: true

- name: Initialize mandatory git config
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Bump version in values/stage.yaml
run: yq -i '.deployment.image.tag=strenv(COMMIT_SHA)' ./k8s/values/stage.yaml

- name: Commit k8s values files
id: make-commit
run: |
git add ./k8s/values/stage.yaml
git commit --message "Update stage image to commit ${{ env.COMMIT_SHA }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push changes
uses: CasperWA/push-protected@v2
if: github.event_name == 'push'
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/${{ env.RELEASE_VERSION }}

- name: Push changes
uses: CasperWA/push-protected@v2
if: github.event_name == 'workflow_dispatch'
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: develop

- name: Delete tag
uses: dev-drprasad/[email protected]
with:
tag_name: stage-deployment
delete_release: false
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create tag
run: git tag -fa 'stage-deployment' -m "Update tag to commit ${{ env.COMMIT_SHA }}"

- name: Push tag
run: git push origin stage-deployment
31 changes: 31 additions & 0 deletions .github/workflows/build-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Build project on PR"

on:
pull_request:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn --frozen-lockfile

- name: Build project
run: yarn build
72 changes: 72 additions & 0 deletions .github/workflows/cleanup_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'Cleanup Pull Request'
on:
pull_request:
types: [closed]

jobs:
check-resources:
name: "Check Resources"
runs-on: ubuntu-latest
outputs:
helm_exists: ${{ steps.check_helm.outputs.exists }}
namespace_exists: ${{ steps.check_namespace.outputs.exists }}

steps:
- name: Kubernetes login
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}

- name: Check Helm Chart
id: check_helm
run: |
RELEASE_NAME=project-website-pr-${{ github.event.number }}
if helm list --all --namespace $RELEASE_NAME | grep $RELEASE_NAME; then
echo "::set-output name=exists::true"
else
echo Helm Chart $RELEASE_NAME does not exist
echo "::set-output name=exists::false"
fi
- name: Check Namespace
id: check_namespace
run: |
NAMESPACE=project-website-pr-${{ github.event.number }}
if kubectl get namespace $NAMESPACE; then
echo "::set-output name=exists::true"
else
echo Namespace $NAMESPACE does not exist
echo "::set-output name=exists::false"
fi
cleanup-pr:
name: "Cleanup Pull Request"
runs-on: ubuntu-latest
needs: check-resources
if: needs.check-resources.outputs.helm_exists == 'true' || needs.check-resources.outputs.namespace_exists == 'true'
continue-on-error: true
permissions:
contents: read
packages: write
actions: write
pull-requests: write

steps:
- name: Kubernetes login
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}

- name: Delete Helm Chart
if: needs.check-resources.outputs.helm_exists == 'true'
run: |
RELEASE_NAME=project-website-pr-${{ github.event.number }}
helm delete $RELEASE_NAME --namespace $RELEASE_NAME
- name: Delete Namespace
if: needs.check-resources.outputs.namespace_exists == 'true'
run: |
NAMESPACE=project-website-pr-${{ github.event.number }}
kubectl delete namespace $NAMESPACE
Loading

0 comments on commit 9b0a611

Please sign in to comment.