Skip to content

Commit

Permalink
ci: Complete rework of CI/CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
steilerDev committed Jul 3, 2023
1 parent aaceee5 commit e2ad084
Show file tree
Hide file tree
Showing 57 changed files with 27,739 additions and 612 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Issue Template
about: General issue template for icloud-photos-sync
title: ''
labels: open
labels: new
assignees: ''

---
Expand All @@ -18,15 +18,15 @@ A clear and concise description of what the bug is.

**Error code**

Share the Error Code generated upon the crash
[Enable crash and error reporting](https://steilerdev.github.io/icloud-photos-sync/user-guides/error-reporting/) and share the Error Code generated upon the crash.

```
e.g. `10000000-0000-0000-0000-000000000000`
```

**Logs**

Please paste the log file (preferably with `LOG_LEVEL=debug`), located in `.icloud-photos-sync.log`, stored in the `DATA_DIR`.
Please paste the log file (with `LOG_LEVEL=debug`), located in `.icloud-photos-sync.log`, stored in the `DATA_DIR`.

```
.icloud-photos-sync.log
Expand Down
22 changes: 22 additions & 0 deletions .github/actions/build/app-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-app-setup
description: Sets up the environment for the app build action
inputs:
app-path:
description: The path to the app directory
required: false
default: app
runs:
using: composite
steps:
- id: setup-node
uses: actions/setup-node@v3
with:
node-version-file: ${{ inputs.app-path }}/node-version
cache: npm
cache-dependency-path: ${{ inputs.app-path }}
- id: setup-npm
shell: bash
run: (cd ${{ inputs.app-path }}; npm ci)
- id: setup-fs
shell: bash
run: cp README.md LICENSE ${{ inputs.app-path }}/
27 changes: 27 additions & 0 deletions .github/actions/build/app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build-app
description: Builds the JS application and uploads the artifact
inputs:
app-path:
description: The path to the app directory
required: false
default: app
artifact-name:
description: The name of the uploaded app artifact
required: false
default: app-artifact
runs:
using: composite
steps:
- id: build-app
shell: bash
run: (cd ${{ inputs.app-path }}; npm run build)
- id: package-artifact
shell: bash
run: |
fileName=$(cd ${{ inputs.app-path }}; npm pack)
mv ${{ inputs.app-path }}/$fileName npm-pack.tgz
- id: upload-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: npm-pack.tgz
26 changes: 26 additions & 0 deletions .github/actions/build/docker-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-docker-setup
description: Sets up the environment for cross platform docker build action
inputs:
docker-path:
description: The path to the docker directory
required: false
default: docker
app-artifact-name:
description: The name of the uploaded app artifact
required: false
default: app-artifact
runs:
using: composite
steps:
- id: setup-qemu
uses: docker/setup-qemu-action@v2
- id: setup-buildx
uses: docker/setup-buildx-action@v2
- id: setup-app-artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.app-artifact-name }}
path: ${{ inputs.docker-path }}/rootfs/opt/
- id: debug
shell: bash
run: ls -al ${{ inputs.docker-path }}/rootfs/opt/
45 changes: 45 additions & 0 deletions .github/actions/build/docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build-docker
description: Builds the cross platform docker containers and uploads the artifact
inputs:
docker-path:
description: The path to the docker directory
required: false
default: docker
artifact-name:
description: The name of the uploaded docker artifact
required: false
default: docker-artifact
runs:
using: composite
steps:
- id: get-docker-metadata
uses: ./.github/actions/helper/docker-metadata
- id: build-rootfs
shell: bash
run: tar -C ${{ inputs.docker-path }}/rootfs -czf ${{ inputs.docker-path }}/rootfs.tar.gz ./
- id: build-docker-amd64
uses: docker/build-push-action@v4
with:
context: ${{ inputs.docker-path }}
platforms: linux/amd64
tags: ${{ steps.get-docker-metadata.outputs.image-namespace }}/${{ steps.get-docker-metadata.outputs.image-repository }}:${{ steps.get-docker-metadata.outputs.image-tag }}
outputs: type=docker,dest=docker-amd64.tar
- id: build-docker-arm64
uses: docker/build-push-action@v4
with:
context: ${{ inputs.docker-path }}
platforms: linux/arm64
tags: ${{ steps.get-docker-metadata.outputs.image-namespace }}/${{ steps.get-docker-metadata.outputs.image-repository }}:${{ steps.get-docker-metadata.outputs.image-tag }}
outputs: type=docker,dest=docker-arm64.tar
- id: package-artifact
shell: bash
run: |
mkdir docker-artifact
gzip docker-*.tar
mv docker-*.tar.gz docker-artifact/
echo "artifact-path=docker-artifact/" >> $GITHUB_OUTPUT
- name: upload-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: ${{ steps.package-artifact.outputs.artifact-path }}
41 changes: 41 additions & 0 deletions .github/actions/build/docs-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build-docs-setup
description: Sets up the environment for the docs build action using mkdocs
inputs:
docs-path:
description: The path to the mkdocs directory
required: false
default: docs
app-path:
description: The path to the app directory
required: false
default: app
app-artifact-name:
description: The name of the uploaded app artifact
required: false
default: app-artifact
runs:
using: composite
steps:
- id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: pip
cache-dependency-path: ${{ inputs.docs-path }}
- id: setup-pip
shell: bash
run: pip install -r ${{ inputs.docs-path }}/requirements.txt
- id: setup-node
uses: actions/setup-node@v3
with:
node-version-file: ${{ inputs.app-path }}/node-version
- id: download-app-artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.app-artifact-name }}
path: ${{ inputs.app-path }}
- id: install-app-artifact
shell: bash
run: |
tree -a ${{ inputs.app-path }}
npm install -g ./${{ inputs.app-path }}/npm-pack.tgz
45 changes: 45 additions & 0 deletions .github/actions/build/docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build-docs
description: Builds the docs using mkdocs
inputs:
docs-path:
description: The path to the docs directory
required: false
default: docs
app-path:
description: The path to the app directory
required: false
default: app
runs:
using: composite
steps:
- id: get-docs-config
shell: bash
run: |
echo "site-dir=$(grep -oP "site_dir: '\K.+'" ${{ inputs.docs-path }}/mkdocs.yml | head -c-2)" >> $GITHUB_OUTPUT
echo "docs-dir=$(grep -oP "docs_dir: '\K.+'" ${{ inputs.docs-path }}/mkdocs.yml | head -c-2)" >> $GITHUB_OUTPUT
- id: get-npm-metadata
uses: ./.github/actions/helper/npm-metadata
with:
package: ${{ inputs.app-path }}/package.json
- id: setup-fs
shell: bash
run: cp README.md LICENSE ${{ inputs.docs-path }}/${{ steps.get-docs-config.outputs.docs-dir }}/
- id: build-cli-reference
shell: bash
run: ${{ github.action_path }}/build_cli.sh "${{ inputs.docs-path }}/${{ steps.get-docs-config.outputs.docs-dir }}" "${{ steps.get-npm-metadata.outputs.command }}"
- id: build-mkdocs
shell: bash
run: (cd ${{ inputs.docs-path }}; mkdocs build)
- id: bundle-coverage
uses: dawidd6/action-download-artifact@v2
with:
name: coverage-artifact
path: ${{ inputs.docs-path }}/${{ steps.get-docs-config.outputs.site-dir }}/dev/coverage
workflow: event_pr.yml
workflow_conclusion: ""
branch: beta
if_no_artifact_found: warn
- id: upload-artifact
uses: actions/upload-pages-artifact@v1
with:
path: ${{ inputs.docs-path }}/${{ steps.get-docs-config.outputs.site-dir }}
38 changes: 38 additions & 0 deletions .github/actions/build/docs/build_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

OUT_FILE="$1/user-guides/cli.md"
BIN="$2"
> $OUT_FILE

echo '# CLI Reference' >> $OUT_FILE
echo '' >> $OUT_FILE
echo '```' >> $OUT_FILE
$BIN --help >> $OUT_FILE
echo '```' >> $OUT_FILE
echo '' >> $OUT_FILE

echo '## `token` command' >> $OUT_FILE
echo '' >> $OUT_FILE
echo '```' >> $OUT_FILE
$BIN token --help >> $OUT_FILE
echo '```' >> $OUT_FILE
echo '' >> $OUT_FILE

echo '## `sync` command' >> $OUT_FILE
echo '' >> $OUT_FILE
echo '```' >> $OUT_FILE
$BIN sync --help >> $OUT_FILE
echo '```' >> $OUT_FILE
echo '' >> $OUT_FILE

echo '## `archive` command' >> $OUT_FILE
echo '' >> $OUT_FILE
echo '```' >> $OUT_FILE
$BIN archive --help >> $OUT_FILE
echo '```' >> $OUT_FILE

echo '## `daemon` command' >> $OUT_FILE
echo '' >> $OUT_FILE
echo '```' >> $OUT_FILE
$BIN daemon --help >> $OUT_FILE
echo '```' >> $OUT_FILE
22 changes: 22 additions & 0 deletions .github/actions/build/wiki-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-wiki-setup
description: Sets up the environment for the wiki build action
inputs:
app-path:
description: The path to the app directory
required: false
default: app
runs:
using: composite
steps:
- id: setup-node
uses: actions/setup-node@v3
with:
node-version-file: ${{ inputs.app-path }}/node-version
cache: npm
cache-dependency-path: ${{ inputs.app-path }}
- id: setup-npm
shell: bash
run: (cd ${{ inputs.app-path }}; npm ci)
- id: setup-fs
shell: bash
run: cp README.md LICENSE ${{ inputs.app-path }}/
27 changes: 27 additions & 0 deletions .github/actions/build/wiki/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build-wiki
description: Builds the Github Wiki Pages and uploads the artifact
inputs:
app-path:
description: The path to the app directory
required: false
default: app
artifact-name:
description: The name of the uploaded wiki artifact
required: false
default: wiki-artifact
runs:
using: composite
steps:
- id: build-typedoc
shell: bash
run: (cd ${{ inputs.app-path }}; npx typedoc)
- id: package-artifact
shell: bash
run: |
outDir=$(cat ${{ inputs.app-path }}/typedoc.json | jq -r .out)
echo "artifact-path=${{ inputs.app-path }}/$outDir" >> $GITHUB_OUTPUT
- name: upload-artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: ${{ steps.package-artifact.outputs.artifact-path }}
20 changes: 20 additions & 0 deletions .github/actions/helper/clean-after-prod-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: clean-after-prod-release
description: Merges the tags from the main branch to the dev branch and clears nightly tags
inputs:
gh-token:
description: The Github token
required: true
runs:
using: composite
steps:
- id: merge-main-to-dev
uses: devmasx/merge-branch@master
with:
type: now
from_branch: main
target_branch: dev
message: merge main into dev
github_token: ${{ inputs.gh-token }}
- id: clear-nightly-tags
shell: bash
run: git push origin --delete $(git tag -l "$(git describe --tags --abbrev=0)-nightly*")
13 changes: 13 additions & 0 deletions .github/actions/helper/clear-git-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: clear-git-tag
description: Removes the provided git tag from the remote repository
inputs:
git-tag:
description: The git tag to remove
required: true
runs:
using: composite
steps:
- id: get-config
if: inputs.git-tag != ''
shell: bash
run: git push --delete origin ${{ inputs.git-tag }}
21 changes: 21 additions & 0 deletions .github/actions/helper/docker-metadata/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: docker-metadata
description: Retrieves the relevant Docker metadata
outputs:
image-namespace:
description: The image namespace for CI built Docker images
value: ${{ steps.get-config.outputs.image-namespace }}
image-repository:
description: The image repository name for CI built Docker images
value: ${{ steps.get-config.outputs.image-repository }}
image-tag:
description: The image tag for CI built Docker images
value: ${{ steps.get-config.outputs.image-tag }}
runs:
using: composite
steps:
- id: get-config
shell: bash
run: |
echo "image-namespace=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "image-repository=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT
echo "image-tag=latest-ci-build" >> $GITHUB_OUTPUT

0 comments on commit e2ad084

Please sign in to comment.