diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index c444eefbc..818223211 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -1,13 +1,11 @@ name: Update cache from SVN on: - push: - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - schedule: - - cron: '59 */3 * * *' # every third hour to keep cache up to date + #schedule: + #- cron: '59 */3 * * *' # every third hour to keep cache up to date jobs: # This workflow contains a single job called "build" @@ -70,9 +68,9 @@ jobs: run: | echo "::group::git svn init" git svn init --trunk=trunk --tags=tags --prefix=svn/ https://svn.fhem.de/fhem; - git config --add svn.authorsfile "${GITHUB_WORKSPACE}/authors/authors_merged.txt" - git config --add svn-remote.svn.preserve-empty-dirs "true" ; - git config --add svn-remote.svn.placeholder-filename ".gitkeep" ; + git config --replace-all svn.authorsfile "${GITHUB_WORKSPACE}/authors/authors_merged.txt" + git config --replace-all svn-remote.svn.preserve-empty-dirs "true" ; + git config --replace-all svn-remote.svn.placeholder-filename ".gitkeep" ; echo "Current .git/config file content:"; cat ${GITHUB_WORKSPACE}/src/fhem-mirror/.git/config; echo "::endgroup::" diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index f0644c5bc..49b175388 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -32,26 +32,35 @@ jobs: - name: Get current date as seconds id: get-date run: | - echo "::set-output name=seconds::$(/bin/date -u "+%s")" + echo "::set-output name=timestamp::$(/bin/date -u "+%Y%m%d%H" )" shell: bash - name: generate merged authors file run: | + ls -RLa ${GITHUB_WORKSPACE} cd /tmp + mkdir -p ${GITHUB_WORKSPACE}/authors svn log https://svn.fhem.de/fhem --xml --quiet | grep author | sort -u | perl -pe 's/.*>(.*?)<.*/$1 = $1 <>/' > ${GITHUB_WORKSPACE}/authors_svn.txt; - cat ${GITHUB_WORKSPACE}/authors.txt ${GITHUB_WORKSPACE}/authors_svn.txt | sort -u -k1,1 > ${GITHUB_WORKSPACE}/authors_merged.txt; - ls -la ${GITHUB_WORKSPACE}/authors_merged.txt; + cat ${GITHUB_WORKSPACE}/authors.txt ${GITHUB_WORKSPACE}/authors_svn.txt | sort -u -k1,1 > ${GITHUB_WORKSPACE}/authors/authors_merged.txt; + ls -la ${GITHUB_WORKSPACE}/authors/authors_merged.txt; - name: Cache runners svn-2-git-fhem mirror directory # Some room for improvement because we create a new cache on every run where a new ref is fetched, this isn't very nice, normaly weneed only the last one and it takes 7 days until they are deleted id: cache-fhem uses: actions/cache@v2.1.7 with: - path: ./src/fhem-mirror - key: ${{ runner.os }}-fhemsvnmirror-${{ steps.get-date.outputs.seconds }} + path: ./src/fhem-mirror/.git + key: ${{ runner.os }}-fhemsvndir-${{ steps.get-date.outputs.timestamp }} restore-keys: | - ${{ runner.os }}-fhemsvnmirror- + ${{ runner.os }}-fhemsvndir- + + #- name: 'Tar files' + # run: tar -cvf ${GITHUB_WORKSPACE}/svnMirror.tar ./src/fhem-mirror/ + #- uses: actions/upload-artifact@v2 + # with: + # name: mirror-artifact + # path: ./svnMirror.tar - name: init mirror repository if it is not already a mirror timeout-minutes: 1800 @@ -59,10 +68,10 @@ jobs: if [[ ! -d "${GITHUB_WORKSPACE}/src/fhem-mirror/.git" ]]; then git init "${GITHUB_WORKSPACE}/src/fhem-mirror" ; cd "${GITHUB_WORKSPACE}/src/fhem-mirror"; - git svn init --trunk=trunk --prefix=svn/ --no-metadata https://svn.fhem.de/fhem ; - git config --add svn-remote.svn.preserve-empty-dirs "true" ; - git config --add svn-remote.svn.placeholder-filename ".gitkeep" ; - git config --add svn.authorsfile "${GITHUB_WORKSPACE}/authors_merged.txt" ; + git svn init --trunk=trunk --tags=tags --prefix=svn/ https://svn.fhem.de/fhem; + git config --replace-all svn-remote.svn.preserve-empty-dirs "true" ; + git config --replace-all svn-remote.svn.placeholder-filename ".gitkeep" ; + git config --replace-all svn.authorsfile "${GITHUB_WORKSPACE}/authors_merged.txt" ; # Run extra fetches after init, go pick up some base refs for the cache on first run only! timeout 300 git svn -q fetch || timeout 300 git svn -q fetch || timeout 300 git svn -q fetch || true else @@ -79,8 +88,12 @@ jobs: RET=0 timeout 1200 git svn -q fetch || timeout 120 git svn -q fetch || RET=$?; # Limit each run to 20 minutes to not overload fhem.de servers and build cache in chunks if [[ $RET == 0 ]]; then - git checkout -f "master" - git rebase "remotes/svn/trunk" + git checkout travis + git branch -f master + git checkout master + git config --global user.email "actions@gitbhub.com" + git config --global user.name "Github Actions" + git reset --hard "remotes/svn/trunk" echo "::set-output name=SVN_FETCH_STATUS::complete" elif [[ $RET != 124 ]]; then echo "::set-output name=SVN_FETCH_STATUS::error" @@ -110,7 +123,7 @@ jobs: uses: ad-m/github-push-action@v0.6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - branch: master + branch: main directory: ./src/fhem-mirror force: true - tags: true \ No newline at end of file + tags: true diff --git a/.travis.yml.old b/.travis.yml.old deleted file mode 100644 index 28db6ae94..000000000 --- a/.travis.yml.old +++ /dev/null @@ -1,90 +0,0 @@ -dist: xenial -sudo: required -language: bash - -addons: - apt: - sources: - - github-git-lfs-xenial - - ppa:git-core/ppa - packages: - - git - - subversion - - libsvn-perl - - libyaml-perl - - libterm-readkey-perl - -branches: - only: - - travis - -notifications: - email: false - -before_install: | - cd /tmp - apt-get download git-svn; - sudo dpkg --ignore-depends=git -i git-svn*.deb; - rvm all do gem install svn2git; - sudo sed -i 's/die "Failed to strip path/print "Failed to strip path/g' `find /usr -name Fetcher.pm -type f 2> /dev/null | grep Git | head -n 1`; - svn log -q https://svn.fhem.de/fhem --xml --quiet | grep author | sort -u | perl -pe 's/.*>(.*?)<.*/$1 = $1 <>/' > $TRAVIS_BUILD_DIR/authors_svn.txt; - cat $TRAVIS_BUILD_DIR/authors.txt $TRAVIS_BUILD_DIR/authors_svn.txt | sort -u -k1,1 > $TRAVIS_BUILD_DIR/authors_merged.txt; - ls -la $TRAVIS_BUILD_DIR/authors_merged.txt; - if [[ ! -d "$TRAVIS_BUILD_DIR/src/fhem-mirror/.git" ]]; then - git init "$TRAVIS_BUILD_DIR/src/fhem-mirror" ; - cd "$TRAVIS_BUILD_DIR/src/fhem-mirror"; - git svn init --trunk=trunk --prefix=svn/ --no-metadata https://svn.fhem.de/fhem ; - git config --add svn-remote.svn.preserve-empty-dirs "true" ; - git config --add svn-remote.svn.placeholder-filename ".gitkeep" ; - git config --add svn.authorsfile "$TRAVIS_BUILD_DIR/authors_merged.txt" ; - else - echo "Current .git/config file content:"; - cat $TRAVIS_BUILD_DIR/src/fhem-mirror/.git/config; - fi - -install: | - export SVN_FETCH_STATUS="incomplete"; - cd "$TRAVIS_BUILD_DIR/src/fhem-mirror"; - timeout 2790 git svn -q fetch ; - RET=$? ; - if [[ $RET == 0 ]]; then - export SVN_FETCH_STATUS="complete"; - git checkout -f "master" - git rebase "remotes/svn/trunk" - elif [[ $RET != 124 ]]; then - export SVN_FETCH_STATUS="error"; - fi - -script: | - if [[ "$SVN_FETCH_STATUS" == "error" ]]; then - echo "A permanent error occured" - exit 1 - elif [[ "$SVN_FETCH_STATUS" != "complete" ]]; then - if [[ -n "$TRAVIS_API_TOKEN" ]]; then - body='{"request":{"branch":"travis","message":"Extend build runtime"}}'; - curl -s -X POST \ - -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $TRAVIS_API_TOKEN" -d "$body" https://api.travis-ci.com/repo/fhem%2Ffhem-mirror/requests ; - else - echo "TRAVIS_API_TOKEN missing - unable to automatically trigger next build run" - fi - fi - -cache: - directories: - - $TRAVIS_BUILD_DIR/src/fhem-mirror/ - -after_success: | - if [[ "$SVN_FETCH_STATUS" != "complete" ]]; then - echo "Maximum runtime reached - will continue next run!"; - elif [[ -n "$GITHUB_API_KEY" ]]; then - cd "$TRAVIS_BUILD_DIR/src/fhem-mirror"; - echo "Will now push the following directory structure to remote repo:"; - ls -la ; - git remote add origin https://jpawlowski:$GITHUB_API_KEY@github.com/fhem/fhem-mirror.git ; - git config --add remote.origin.push 'refs/remotes/svn/trunk:refs/heads/master' ; - git push --follow-tags --force origin master ; - git remote remove origin ; - else - echo "GITHUB_API_KEY missing - unable to push updated repository"; - exit 1; - fi