This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
chore(deps): update dependency @bifravst/eslint-config-typescript to … #1377
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Release | |
on: | |
push: | |
branches: | |
- saga | |
- "v*" | |
permissions: | |
packages: write | |
contents: write | |
actions: write | |
jobs: | |
docker: | |
name: Prepare Docker image | |
runs-on: ubuntu-22.04 | |
outputs: | |
docker_image: ${{ steps.docker-image-tag.outputs.docker_image }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Determine Docker image name and tag | |
id: docker-image-tag | |
run: | | |
DOCKER_REPO_NAME=`echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]'` | |
DOCKER_CHECKSUM=`cat Dockerfile scripts/dot2svg.sh scripts/sphinx.sh | sha256sum | awk '{ print $1 }' | tr -d '\n'` | |
DOCKER_IMAGE=ghcr.io/${DOCKER_REPO_NAME}/builder:${DOCKER_CHECKSUM} | |
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT | |
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV | |
- name: Check if Docker image exists | |
id: check-docker-image | |
continue-on-error: true | |
env: | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
run: docker manifest inspect ${{ env.DOCKER_IMAGE }} | |
- name: Build Docker image | |
if: steps.check-docker-image.outcome == 'failure' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
tags: ${{ env.DOCKER_IMAGE }} | |
push: true | |
build: | |
name: "Build the documentation" | |
runs-on: ubuntu-22.04 | |
needs: [docker] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Pull Docker image | |
run: | | |
docker pull ${{ needs.docker.outputs.docker_image }} | |
echo "DOCKER_IMAGE=${{ needs.docker.outputs.docker_image }}" >> $GITHUB_ENV | |
- name: Build docs | |
run: make html | |
- uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: asset-tracker-docs-${{ github.sha }} | |
path: build/html/ | |
test: | |
name: "Run the tests" | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
cache: "npm" | |
- run: npm ci --no-audit | |
- run: npx tsc | |
- name: Compile TypeScript | |
run: npx tsc | |
- name: Check source code with eslint | |
run: npx eslint ./ | |
- name: Check if source code is properly formatted | |
run: npx prettier -c ./ | |
- run: npm test | |
release: | |
name: Release | |
runs-on: ubuntu-22.04 | |
needs: [build, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
cache: "npm" | |
- run: npm ci --no-audit | |
- name: Semantic release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
id: semantic-release | |
continue-on-error: true | |
run: npx semantic-release | |
publish: | |
name: Publish the documentation | |
runs-on: ubuntu-22.04 | |
needs: [build, test, release, docker] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Determine documentation release | |
if: github.ref == 'refs/heads/saga' | |
run: | | |
git fetch --tags | |
RELEASE=`git describe --abbrev=0 --tags --always | tr -d '\n'` | |
VERSION=`git rev-parse --abbrev-ref HEAD | tr -d '\n'` | |
echo "VERSION=saga" >> $GITHUB_ENV | |
echo "RELEASE=$RELEASE" >> $GITHUB_ENV | |
- name: Determine documentation release (maintenance branches) | |
if: github.ref != 'refs/heads/saga' | |
run: | | |
echo "VERSION=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | |
echo "RELEASE=${{ github.sha }}" >> $GITHUB_ENV | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Pull Docker image | |
run: | | |
docker pull ${{ needs.docker.outputs.docker_image }} | |
echo "DOCKER_IMAGE=${{ needs.docker.outputs.docker_image }}" >> $GITHUB_ENV | |
- name: Build documentation | |
if: env.RELEASE != '' && env.VERSION != '' | |
run: | | |
echo "Updating documentation for version ${{ env.VERSION }} release ${{ env.RELEASE }}..."; | |
# Generate Documentation | |
make html | |
# Clone gh-pages branch | |
git clone --single-branch --branch gh-pages https://github.com/${GITHUB_REPOSITORY} asset-tracker-docs | |
git -C asset-tracker-docs rm -r ${{ env.VERSION }}/\* | |
mkdir -p asset-tracker-docs/${{ env.VERSION }} | |
cp -r build/html/* asset-tracker-docs/${{ env.VERSION }} | |
git -C asset-tracker-docs add -A ${{ env.VERSION }} | |
if [[ `git -C asset-tracker-docs status --porcelain` ]]; then | |
echo "HAS_CHANGES=1" >> $GITHUB_ENV | |
git -C asset-tracker-docs status | |
else | |
echo "HAS_CHANGES=0" >> $GITHUB_ENV | |
echo "No changes." | |
fi | |
- name: Publish documentation | |
if: env.HAS_CHANGES == '1' | |
run: | | |
cd asset-tracker-docs | |
echo "machine github.com login accesskey password ${{ secrets.GITHUB_TOKEN }}" > ~/.netrc | |
git config --global user.email "actions@example.com" | |
git config --global user.name "github-actions[bot]" | |
touch .nojekyll | |
git add .nojekyll | |
git commit -m "docs(${{ env.VERSION }}): update documentation for release ${{ env.RELEASE }}" | |
git pull --rebase | |
git push | |
- name: Trigger publish docs zoomin workflow | |
if: env.HAS_CHANGES == '1' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh workflow run publish-docs-zoomin.yaml --field name=asset-tracker-docs-${{ github.sha }} --field version="${{ env.VERSION }}" |