From 93f36a282bf217f77272ea4615250123da14c43a Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 3 Jul 2024 10:57:16 +0800 Subject: [PATCH] refactor: move to github actions to build site --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ .travis.yml | 27 ------------------ 2 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..80e467c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build Site + +on: + push: + branches: ['sources', 'generator'] + pull_request: + branches: ['sources', 'generator'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: sources + path: sources + + - uses: actions/checkout@v4 + with: + ref: generator + path: generator + + - name: Copy files + run: | + cp -a generator/webroot workdir + cp -a sources/{post,content.php,index.md} generator/{mdgen.py,sitegen.php} workdir + mv workdir/img/favicon.ico workdir/favicon.ico + + - name: Generate site + run: | + cd workdir + php sitegen.php + rm -r post/*.md index.md *.{py,php} + + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v1 + with: + path: workdir + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + permissions: + contents: read + pages: write + id-token: write + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cb1fe40..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -dist: xenial -sudo: required -language: python - -before_install: - - sudo apt-get install python3-pip - - pip3 install markdown\<3.0.0 pygments - -before_script: - - echo $TRAVIS_COMMIT - - echo $TRAVIS_BRANCH - -script: - - git clone https://github.com/${TRAVIS_REPO_SLUG}.git sources --depth 1 -b sources - - git clone https://github.com/${TRAVIS_REPO_SLUG}.git generator --depth 1 -b generator - - cp -a generator/webroot workdir && cp -a sources/{post,content.php,index.md} generator/{mdgen.py,sitegen.php} workdir - - cd workdir && mv img/favicon.ico . && php sitegen.php && rm -r post/*.md index.md *.{py,php} - -deploy: - provider: pages - skip-cleanup: true - keep-history: true - github-token: $GITHUB_TOKEN - local-dir: workdir - target-branch: master - on: - branch: sources