Skip to content

Validate GitLab credentials in workflow #68

Validate GitLab credentials in workflow

Validate GitLab credentials in workflow #68

Workflow file for this run

name: Publish website
on:
push:
branches:
- main
jobs:
build_and_deploy:
name: Build & deploy website
runs-on: ubuntu-latest
if: github.repository == 'Orange-OpenSource/Tota11ylost'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Generate firebaseConfig.js
run: |
echo "window.env = {" > ./src/firebaseConfig.js
echo " FIREBASE_API_KEY: '${{ secrets.FIREBASE_API_KEY }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_AUTH_DOMAIN: '${{ secrets.FIREBASE_AUTH_DOMAIN }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_PROJECT_ID: '${{ secrets.FIREBASE_PROJECT_ID }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_STORAGE_BUCKET: '${{ secrets.FIREBASE_STORAGE_BUCKET }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_MESSAGING_SENDER_ID: '${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_APP_ID: '${{ secrets.FIREBASE_APP_ID }}'," >> ./src/firebaseConfig.js
echo " FIREBASE_MEASUREMENT_ID: '${{ secrets.FIREBASE_MEASUREMENT_ID }}'" >> ./src/firebaseConfig.js
echo "};" >> ./src/firebaseConfig.js
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3.6.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src
cname: tota11ylost.orange.com
wait_for_deployment:
name: Wait for deployed website
needs: build_and_deploy
runs-on: ubuntu-latest
steps:
- name: Wait for GitHub Pages
run: |
set -eu
for attempt in $(seq 1 30); do
if curl \
--fail \
--silent \
--show-error \
--output /dev/null \
"https://tota11ylost.orange.com"; then
echo "Website is reachable."
exit 0
fi
echo "Website not ready yet: attempt ${attempt}/30"
sleep 10
done
echo "Website did not become reachable before timeout."
exit 1
accessibility:
name: Accessibility scan
needs: wait_for_deployment
runs-on: ubuntu-latest
continue-on-error: true
container:
image: mcr.microsoft.com/playwright:v1.60.0-noble
env:
A11Y_URLS: "https://tota11ylost.orange.com"
A11Y_TEST_TYPE: "essentials"
A11Y_TARGET: "web"
steps:
- name: Clone tota11y-scan from GitLab
if [ -z "${GITLAB_USERNAME:-}" ]; then
echo "TOTA11Y_GITLAB_USERNAME is missing"
exit 1
fi
if [ -z "${GITLAB_TOKEN:-}" ]; then
echo "TOTA11Y_GITLAB_TOKEN is missing"
exit 1
fi
echo "GitLab username is configured."
echo "GitLab token is configured."
echo "Testing repository access..."
git ls-remote \
"https://gitlab.tech.orange/damien.gomez/tota11y-scan.git" \
HEAD
env:
GITLAB_USERNAME: ${{ secrets.TOTA11Y_GITLAB_USERNAME }}
GITLAB_TOKEN: ${{ secrets.TOTA11Y_GITLAB_TOKEN }}
SCANNER_REF: "main"
run: |
set -eu
printf '%s\n' \
"machine gitlab.tech.orange" \
"login ${GITLAB_USERNAME}" \
"password ${GITLAB_TOKEN}" \
> "${HOME}/.netrc"
chmod 600 "${HOME}/.netrc"
git clone \
--depth 1 \
--branch "${SCANNER_REF}" \
"https://gitlab.tech.orange/damien.gomez/tota11y-scan.git" \
.tota11y-scan
rm -f "${HOME}/.netrc"
- name: Configure private npm registry
working-directory: .tota11y-scan
env:
GITLAB_TOKEN: ${{ secrets.TOTA11Y_GITLAB_TOKEN }}
run: |
set -eu
npm config set \
@tota11y-scan:registry \
"https://gitlab.tech.orange/api/v4/projects/574357/packages/npm/"
npm config set -- \
"//gitlab.tech.orange/api/v4/projects/574357/packages/npm/:_authToken" \
"${GITLAB_TOKEN}"
- name: Install scanner
working-directory: .tota11y-scan
run: |
npm ci
node scripts/patch-engine-auth.js
npx playwright install --with-deps chromium
- name: Run accessibility scan
working-directory: .tota11y-scan
run: npm run ci:a11y
- name: Upload accessibility reports
if: always()
uses: actions/upload-artifact@v4
with:
name: accessibility-reports
path: |
.tota11y-scan/a11y-report.json
.tota11y-scan/reports
if-no-files-found: warn
retention-days: 30