From b97380f133518b13d5994f9ef7108020605e945f Mon Sep 17 00:00:00 2001 From: dolfinus Date: Fri, 26 Mar 2021 00:13:15 +0300 Subject: [PATCH] Automatically update emails list --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ .github/workflows/sync.yml | 51 +++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6a4578e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Releases + +on: + push: + tags: + - .* + +jobs: + release: + name: Release new version + runs-on: ubuntu-latest + + steps: + - name: Wait for tests + uses: fountainhead/action-wait-for-check@v1.0.0 + id: wait-for-tests + with: + token: ${{ secrets.GITHUB_TOKEN }} + checkName: Run dialyzer + ref: ${{ github.ref }} + timeoutSeconds: 3600 + + - name: Set up Elixir + uses: erlef/setup-elixir@v1 + with: + otp-version: "22.2" + elixir-version: "1.9.4" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache deps + id: cache-deps + uses: actions/cache@v2 + with: + path: | + deps + _build + key: deps-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }} + restore-keys: | + deps-${{ runner.os }}-${{ hashFiles('**/mix.lock') }} + deps-${{ runner.os }}-$ + + - name: Install package dependencies + run: mix deps.get + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Publish hex package + run: mix hex.publish --yes + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..d41b46e --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,51 @@ +name: Daily list sync + +on: + schedule: + - cron: "30 15 * * *" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Elixir + uses: erlef/setup-elixir@v1 + with: + otp-version: "22.2" + elixir-version: "1.9.4" + + - name: Download new list + run: curl https://raw.githubusercontent.com/wesbos/burner-email-providers/master/emails.txt -o priv/burner-email-providers/emails.txt + + - name: Check for list changes + continue-on-error: true + id: changes + run: git update-index --refresh && git diff-index HEAD + + - name: Commit changes + if: steps.changes.outcome != 'success' + run: | + git checkout main -- + git config user.email "benjamin@opencollective.com" + git config user.name "Benjamin Piouffle" + git add priv/burner-email-providers/emails.txt + + - name: Bump version + if: steps.changes.outcome != 'success' + run: | + CURRENT_VERSION=`cat VERSION` + NEW_PATCH=`echo $CURRENT_TAG | sed -E 's/v[0-9]+\.[0-9]+\.([0-9]+)/\1+1/' | bc` + NEW_TAG=`echo $CURRENT_TAG | sed -E "s/(v[0-9]+\.[0-9]+\.)[0-9]+/\1$NEW_PATCH/"` + echo $NEW_TAG > VERSION + git commit -m "chore: updated domain list" + git tag -a $NEW_TAG -m $NEW_TAG + + - name: Push changes + if: steps.changes.outcome != 'success' + run: | + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git push --follow-tags \ No newline at end of file