Commit 2c395aba authored by Laura, Jason R's avatar Laura, Jason R
Browse files

Adds back mirroring from GitHub to GitLab

parent ba846e42
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
name: aws-deploy

on:
  push:
    branches:
      - main  # Set a branch to deploy
  pull_request:
  repository_dispatch:
    types: [automated_deploy]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod
      - name: Setup Hugo
        uses: actions/setup-node@a4fcaaf314b117a40d694a35ee36461f8ff3c6e6
        with:
          node-version: 17.3.0
      - name: Build Site
        run: |
          npm install
          npm run build

      - name: Set AWS credentials for upload
        uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-west-2
      
      - name: Upload to S3
        run: aws s3 sync dist s3://asc-stacbrowser/geostac/ --delete
+27 −25
Original line number Diff line number Diff line
stages:
  - build
  - deploy
image: ubuntu:18.04

variables:
  GIT_SSL_NO_VERIFY: 1
  GIT_SUBMODULE_STRATEGY: recursive

build:
  stage: build
  image: code.chs.usgs.gov:5001/asc/stac_browser_deploy
  script:
    - npm install
    - npm run build
  artifacts:
    paths:
      - dist

deploy:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "main"'
clone_github:
    stage: deploy 
  image: usgsastro/aws-cli:latest
  dependencies: 
    - build
    before_script:
        - apt-get update -y && apt-get install openssh-client -y
        - apt install git -y
        - eval $(ssh-agent -s)
        - echo "$GIT_SSH_PRIVATE_KEY" | openssl base64 -A -d | ssh-add -
        - mkdir -p ~/.ssh
        - chmod 700 ~/.ssh
        - ssh-keyscan $GIT_LAB_HOST >> ~/.ssh/known_hosts
        - chmod 644 ~/.ssh/known_hosts
        - git config --global user.name "${GIT_USER_NAME}"
        - git config --global user.email "${GIT_USER_EMAIL}"
        - ssh "git@$GIT_LAB_HOST"
    script:
    - aws s3 sync --delete dist s3://asc-stacbrowser/geostac/
        - echo $SOURCE_REPOSITORY
        - git config --global http.sslVerify false # Epic....
        - rm -rf FoundationalDataProducts  # Needed to allow multiple CI runs
        - git clone --mirror $SOURCE_REPOSITORY FoundationalDataProducts
        - cd FoundationalDataProducts
        - git remote remove origin
        - git remote add origin $DESTINATION_REPOSITORY
        - git push -f --prune --all
        - git push -f --prune --tags
    only:
        - branches