Skip to content

Instantly share code, notes, and snippets.

@qutek
Last active February 12, 2024 18:26
Show Gist options
  • Save qutek/fcdc1aad92059c00ad9d7b93049d48dd to your computer and use it in GitHub Desktop.
Save qutek/fcdc1aad92059c00ad9d7b93049d48dd to your computer and use it in GitHub Desktop.

Revisions

  1. qutek revised this gist Feb 23, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -73,6 +73,7 @@ Deploy to Production:
    cat <<EOT >> deploy.txt
    Commit SHA : ${CI_COMMIT_SHA}
    From ref : ${CI_COMMIT_REF_NAME}
    Date : ${CI_JOB_DATE}
    EOT
    - rsync -a --progress --human-readable --delete
    --exclude-from '.gitignore'
  2. qutek revised this gist Feb 23, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -81,6 +81,7 @@ Deploy to Production:
    .
    [email protected]:/home/admin/web/demo.lafif.me/public_html/deploy
    before_script:
    - export CI_JOB_DATE=$(TZ=Asia/Jakarta date)
    # Setup SSH deploy keys
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
  3. qutek revised this gist Feb 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -70,7 +70,7 @@ Deploy to Production:
    # - ls -a
    # Write log file
    - |
    cat <<EOT >> deploy.log
    cat <<EOT >> deploy.txt
    Commit SHA : ${CI_COMMIT_SHA}
    From ref : ${CI_COMMIT_REF_NAME}
    EOT
  4. qutek created this gist Feb 23, 2020.
    89 changes: 89 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    # https://gitlab.com/help/ci/quick_start/README
    # https://docs.gitlab.com/ee/ci/introduction/
    # https://docs.gitlab.com/ee/ci/yaml/

    image: dpolyakov/docker-node-latest-with-rsync:latest

    # before_script:
    # - apt-get update -qq
    # - apt-get install -qq git

    ##
    # STAGES
    ##
    stages:
    # - build
    # - test
    - deploy

    ##
    # TASKS
    ##
    # Build Dependencies:
    # stage: build
    # script:
    # - echo "Building the app"
    # - node -v
    # # - (cd mu-plugins/mba-project && npm install) # temporary cd and install
    # # - gulp --production
    # # - composer install -d mu-plugins/mba-project
    # only:
    # # - staging
    # - master

    # Test Codes:
    # stage: test
    # script:
    # - echo "Running tests"
    # only:
    # # - staging
    # - master

    Deploy to Staging:
    stage: deploy
    # when: manual
    environment:
    name: staging
    only:
    - master
    script:
    - echo "Deploy to staging server"
    before_script:
    # Setup SSH deploy keys
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    Deploy to Production:
    stage: deploy
    when: manual
    environment:
    name: production
    only:
    - master
    script:
    - echo "Deploying ${CI_COMMIT_SHA} from ${CI_COMMIT_REF_NAME} to production server"
    # - ssh -o PasswordAuthentication=no [email protected] 'exit' || echo "SSH login failed."
    # - rsync --version
    # - ls -a
    # Write log file
    - |
    cat <<EOT >> deploy.log
    Commit SHA : ${CI_COMMIT_SHA}
    From ref : ${CI_COMMIT_REF_NAME}
    EOT
    - rsync -a --progress --human-readable --delete
    --exclude-from '.gitignore'
    --exclude .gitignore
    --exclude .git
    .
    [email protected]:/home/admin/web/demo.lafif.me/public_html/deploy
    before_script:
    # Setup SSH deploy keys
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'