diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6e2cc8e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2.1 - -jobs: - test: - docker: - - image: cimg/base:2023.03 - steps: - - run: echo "" - -workflows: - main: - jobs: - - test diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index 9471a5c..0000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: 'Build and deploy on push to master' -on: - push: - branches: - - 'master' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: docker/build-push-action@v6 - with: - push: false - tags: 'scheme-index:latest' - file: ./build/Dockerfile - - run: | - docker create --name dummy scheme-index:latest - docker cp dummy:/schemeindex.zip /tmp/schemeindex.zip - docker rm -f dummy - - uses: actions/upload-artifact@v4 - with: - name: schemeindex - path: /tmp/schemeindex.zip - - deploy_ansible: - needs: - - build - runs-on: ubuntu-latest - environment: Prod - steps: - - uses: actions/checkout@v4 - - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: actions/download-artifact@v4 - with: - name: schemeindex - path: build - - run: | - sudo apt-get install ansible - ssh-keyscan -t rsa index.scheme.org >> ~/.ssh/known_hosts - cd deploy - ansible-playbook -i hosts deploy.yml -e content_zip_file=$GITHUB_WORKSPACE/build/schemeindex.zip diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..8ff4f80 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,58 @@ +pipeline { + + agent { + label 'docker' + } + + stages { + + stage('Checkout') { + steps { + git changelog: true, branch: "${BRANCH_NAME}", url: 'https://github.com/schemeorg-community/index.scheme.org' + } + } + + stage('Build') { + agent { + docker { + image 'docker:cli' + args "-u root" + reuseNode true + } + } + steps { + sh ''' + docker build -f ./build/Dockerfile . -t scheme-index:latest + docker create --name dummy scheme-index:latest + docker cp dummy:/schemeindex.zip ./schemeindex.zip + docker rm -f dummy + ''' + } + } + + stage('Deploy') { + agent { + dockerfile { + filename './deploy/ansible.Dockerfile' + reuseNode true + } + } + when { + branch 'master' + } + steps { + dir('deploy') { + sh 'pip install ansible' + sshagent(credentials: ['index_scheme_org_ssh']) { + sh ''' + ssh-keyscan -t rsa index.scheme.org >> ~/.ssh/known_hosts + ansible-playbook -i hosts deploy.yml -e content_zip_file=../schemeindex.zip + ''' + } + } + } + } + + } + +} diff --git a/deploy/ansible.Dockerfile b/deploy/ansible.Dockerfile new file mode 100644 index 0000000..a74d327 --- /dev/null +++ b/deploy/ansible.Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9.20 +RUN useradd -ms /bin/bash ansible +USER ansible +RUN pip install ansible +ENV PATH="/home/ansible/.local/bin:$PATH" +RUN mkdir -p /home/ansible/.ssh