EGON-45: Activate manual dispatch #69
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: Continuous integration | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- name: Setup hash env variable | |
run: echo "HASHED_PACKAGE_LOCK=${{ hashFiles('**/package-lock.json') }}" >> $GITHUB_ENV | |
- name: Install latest updates | |
if: ${{ hashFiles(format('node_modules/dependencies-changed-{0}', env.HASHED_PACKAGE_LOCK)) == '' }} | |
run: | | |
npm ci | |
cd node_modules | |
touch "dependencies-changed-$HASHED_PACKAGE_LOCK" | |
cd .. | |
- name: Save cache | |
if: ${{ hashFiles(format('node_modules/dependencies-changed-{0}', env.HASHED_PACKAGE_LOCK)) == '' }} | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
node_modules | |
key: node_modules | |
test: | |
runs-on: ubuntu-latest | |
needs: dependencies | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- run: npm run test | |
format: | |
runs-on: ubuntu-latest | |
needs: dependencies | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- run: npm run format:check | |
build: | |
runs-on: ubuntu-latest | |
needs: [ test, format ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- run: npm run build | |
- name: Cache build | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
dist_build | |
key: build-${{ github.sha }} | |
upload-artifact: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- name: Load build cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
dist_build | |
key: build-${{ github.sha }} | |
- run: npm run zip | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: domain-story-modeler | |
path: | | |
dist/*.zip | |
README.md | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
deploy-website: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- name: Load build cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
dist_build | |
key: build-${{ github.sha }} | |
- run: | | |
sed -i -E "s/version:\s'[0-9]+\.[0-9]+\.[0-9]+'/version: '${{ github.sha }}'/" src/environments/environment.prod.ts | |
sed -i -E "s/\"version\":\s\"[0-9]+\.[0-9]+\.[0-9]+\"/\"version\": \"${{ github.sha }}\"/" package.json | |
CLONE_DIR=$(mktemp -d) | |
git config --global user.email "[email protected]" | |
git config --global user.name "Egon.io Bot" | |
git clone --single-branch --branch main "https://x-access-token:${{ secrets.EGON_IO_DEPLOYMENT_PAT }}@github.com/WPS/egon.io-website.git" "${CLONE_DIR}" | |
rm -r "${CLONE_DIR}/app-latest" | |
mkdir "${CLONE_DIR}/app-latest" | |
cp -r dist_build/egon/* "${CLONE_DIR}/app-latest" | |
cd "${CLONE_DIR}" | |
git add . | |
git commit -m "Deploy latest build" | |
git push | |
publish-image: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup_environment | |
- name: Load build cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
dist_build | |
key: build-${{ github.sha }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: latest |