Modifica: personalizzazione pagina di errore HTTP #568
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 deploy | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
env: | |
IMAGE_CACHE_DIR: '/tmp/cache/docker-image' | |
jobs: | |
build: | |
name: Build release | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
outputs: | |
latest-release: ${{ steps.latest-release.outputs.release }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Get latest release tag | |
id: latest-release | |
uses: rez0n/actions-github-release@main | |
with: | |
token: ${{ github.token }} | |
repository: "iisgiua/giuaschool" | |
type: "stable" | |
- name: Create cache registry | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.IMAGE_CACHE_DIR }} | |
key: ${{ runner.os }}-docker-images-${{ github.sha }} | |
- name: Set up docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build docker image and cache it | |
run: | | |
docker build -t gs:test -f tests/docker/Dockerfile . | |
mkdir -p ${{ env.IMAGE_CACHE_DIR }} | |
docker save --output ${{ env.IMAGE_CACHE_DIR }}/gs-image.tar gs:test | |
- name: Create archive for update code | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
run: | | |
docker build -t gs:prod --target application_prod -f tests/docker/Dockerfile . | |
docker run --name gs_update gs:prod tests/docker/update.sh '${{ steps.latest-release.outputs.release }}' | |
docker cp gs_update:/var/www/giuaschool-update.zip giuaschool-update-${{ steps.latest-release.outputs.release }}.zip | |
- name: Upload update code | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: update-${{ steps.latest-release.outputs.release }} | |
name: "Aggiornamento della versione ${{ steps.latest-release.outputs.release }}" | |
body: "- [Visualizza le modifiche successive al rilascio della versione ${{ steps.latest-release.outputs.release }}](https://iisgiua.github.io/giuaschool-docs/latest-build.html)" | |
draft: false | |
prerelease: true | |
artifacts: giuaschool-update-${{ steps.latest-release.outputs.release }}.zip | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
replacesArtifacts: true | |
test-phpunit: | |
name: PhpUnit tests | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Create cache registry | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.IMAGE_CACHE_DIR }} | |
key: ${{ runner.os }}-docker-images-${{ github.sha }} | |
- name: Docker load | |
run: | | |
docker load --input ${{ env.IMAGE_CACHE_DIR }}/gs-image.tar | |
- name: Run phpunit tests | |
run: | | |
docker run --name gs_test --add-host=giuaschool_test:127.0.0.1 --add-host=chrome_headless:127.0.0.1 gs:test tests/docker/test-phpunit.sh | |
docker cp gs_test:/var/www/giuaschool/clover.xml clover.xml | |
- name: Codacy coverage report | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
uses: codacy/codacy-coverage-reporter-action@master | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: clover.xml | |
feature-matrix: | |
name: Create feature matrix | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set matrix of features | |
id: set-matrix | |
run: echo "matrix=$(ls tests/features/*.feature | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
test-behat: | |
name: Behat tests | |
needs: [build, feature-matrix] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
feature: ${{ fromJson(needs.feature-matrix.outputs.matrix) }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Create cache registry | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.IMAGE_CACHE_DIR }} | |
key: ${{ runner.os }}-docker-images-${{ github.sha }} | |
- name: Set swap space | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 5 | |
- name: Docker load | |
run: | | |
docker load --input ${{ env.IMAGE_CACHE_DIR }}/gs-image.tar | |
- name: Run behat tests | |
run: | | |
docker run --add-host=giuaschool_test:127.0.0.1 --add-host=chrome_headless:127.0.0.1 gs:test tests/docker/test-behat.sh ${{ matrix.feature }} | |
test-update: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
needs: build | |
name: Test update procedure | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
# - name: Test update procedure | |
# run: | | |
# TAG="${{ needs.build.outputs.latest-release }}" | |
# docker build --build-arg VERSION=${TAG:1} --build-arg NEWVERSION="${TAG:1}" --build-arg NEWBUILD="build" -t gs:test -f tests/docker/TestUpdateDockerfile . | |
# docker run --add-host=giuaschool_test:127.0.0.1 --add-host=chrome_headless:127.0.0.1 gs:test | |
deploy: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
needs: [test-phpunit, test-behat, test-update] | |
name: Deploy release | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Generate changelog from latest release | |
id: changelog | |
uses: metcalfc/changelog-generator@v4.3.1 | |
with: | |
myToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate changelog page | |
run: | | |
mkdir docs | |
echo "tag: ${{ github.sha }}" > docs/build.yml | |
echo "---" > docs/latest-build.md | |
echo "layout: default" >> docs/latest-build.md | |
echo "title: Ultimo aggiornamento" >> docs/latest-build.md | |
echo "nav_order: 11" >> docs/latest-build.md | |
echo "---" >> docs/latest-build.md | |
echo "" >> docs/latest-build.md | |
echo "# Ultimo aggiornamento" >> docs/latest-build.md | |
echo "{: .text-center .fw-400 .pb-5}" >> docs/latest-build.md | |
echo "" >> docs/latest-build.md | |
echo "_Le modifiche seguenti non sono ancora validate né definitive:<br>se ne sconsiglia l'installazione se non in ambiente di test_" >> docs/latest-build.md | |
echo "{: .text-center .pb-5}" >> docs/latest-build.md | |
echo "" >> docs/latest-build.md | |
echo "Data e ora dell'ultimo aggiornamento: `TZ='Europe/Rome' date +'%d/%m/%Y %H:%M'`" >> docs/latest-build.md | |
echo "" >> docs/latest-build.md | |
echo "Lista delle modifiche effettuate dopo il rilascio della Versione {{ site.data.version.tag }}:" >> docs/latest-build.md | |
echo "" >> docs/latest-build.md | |
echo "${{ steps.changelog.outputs.changelog }}" >> docs/latest-build.md | |
- name: Add changelog page to documentation | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
with: | |
source_file: 'docs/latest-build.md' | |
destination_repo: 'iisgiua/giuaschool-docs' | |
destination_branch: 'master' | |
user_name: ${{ github.actor }} | |
user_email: '${{ github.actor }}@users.noreply.github.com' | |
commit_message: 'Add changelog page to documentation' | |
- name: Add build tag to documentation | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
with: | |
source_file: 'docs/build.yml' | |
destination_repo: 'iisgiua/giuaschool-docs' | |
destination_branch: 'master' | |
destination_folder: '_data' | |
user_name: ${{ github.actor }} | |
user_email: '${{ github.actor }}@users.noreply.github.com' | |
commit_message: 'Add build tag to documentation' |