Commit 8c8a8efe authored by Ruben ten Hove's avatar Ruben ten Hove 🚵
Browse files

feat: azure + github deploy

parent 5cae0616
Loading
Loading
Loading
Loading
+48 −7
Original line number Diff line number Diff line
@@ -2,21 +2,26 @@
include:
  - local: project-automation/telemetry.yml

pages:
.pages:templates:
  extends: .telemetry
  stage: build
  stage: deploy
  image:
    name: docker.io/alpine/git:latest
    name: docker.io/docker:git
    entrypoint: [""]
  variables:
    GIT_STRATEGY: clone
  script:
    - |
      if command -v apk >/dev/null; then
        apk add -q git grep tree
      elif command -v apt-get >/dev/null; then
        apt-get update -qq && apt-get install -qqy git grep tree
      else
        echo "[-] Winging it with the tools we have. The job may fail."
      fi
    - |
      if [ "$(git rev-parse --is-shallow-repository)" != "false" ]; then
        echo "[*] Repository is shallow. Unshallowing."
        git fetch --unshallow -q
      fi
    - apk add -q grep tree
    - GIT_TAGS=$(git tag --format "%(refname:strip=1)") # Produces list with 'tags/' prefix
    - GIT_BRANCHES=$(git branch -r --format "%(refname:strip=3)")
    - mkdir -p /tmp/public
@@ -46,7 +51,43 @@ pages:
    - cd ${CI_PROJECT_DIR}/public
    - tree -H '.' --noreport --dirsfirst -T "${PAGES_TEMPLATES_NAME:-Templates}"
      --charset utf-8 -o index.html .
  needs: []
  artifacts:
    paths:
      - public
    when: always

pages:
  extends: .pages:templates

pages:templates:github:
  extends: .pages:templates
  script:
    - !reference [".pages:templates", script]
    - mkdir -p ~/.ssh
    - mv "${GITHUB_DEPLOY_KEY}" ~/.ssh/id_ed25519
    - chmod og-rwx ~/.ssh/id_ed25519

    - ssh-keyscan -H github.com >> ~/.ssh/known_hosts

    - git config --global user.name "${GITLAB_USER_NAME}"
    - git config --global user.email "${GITLAB_USER_EMAIL}"

    - git init --initial-branch main
    - git add -A
    - git commit -m "$(date +%Y-%m-%d"_"%H_%M_%S)"
    - git remote add origin git@github.com:CI-Just/jobs.git
    - git push origin main --force
  rules:
    - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $GITHUB_DEPLOY_KEY"

pages:templates:azure:
  extends: .pages:templates
  image:
    name: swacli/static-web-apps-cli:latest
    entrypoint: [""]
  script:
    - !reference [".pages:templates", script]
    - cd ${CI_PROJECT_DIR}
    - swa deploy --no-use-keychain --env production ${CI_PROJECT_DIR}/public
  rules:
    - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $SWA_CLI_DEPLOYMENT_TOKEN"