Check for new SpoofDPI release and build Docker image #11948
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check for new SpoofDPI release and build Docker image | |
on: | |
schedule: | |
- cron: '*/5 * * * *' # Runs every 6 hours (adjust as needed) | |
jobs: | |
check-new-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository so you can perform git operations | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check latest release from SpoofDPI repository | |
id: check_release | |
run: | | |
latest_release=$(curl -s https://api.github.com/repos/xvzc/SpoofDPI/releases/latest | jq -r .tag_name) | |
echo "Latest release tag is $latest_release" | |
# Get the last known release from cache or a file (we'll use a file here for simplicity) | |
if [ -f .last_release ]; then | |
last_known_release=$(cat .last_release) | |
echo "Last known release is $last_known_release" | |
else | |
last_known_release="" | |
fi | |
# Compare the latest release with the last known release | |
if [ "$latest_release" != "$last_known_release" ]; then | |
echo "New release detected: $latest_release" | |
echo "latest_release=$latest_release" >> $GITHUB_ENV | |
else | |
echo "No new release found." | |
exit 0 | |
fi | |
# Commit the new release tag to the repository | |
- name: Save the new release | |
if: env.latest_release | |
run: | | |
echo ${{ env.latest_release }} > .last_release | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add .last_release | |
git commit -m "Update latest release to ${{ env.latest_release }}" | |
git push | |
# Log in to Docker Hub | |
- name: Log in to Docker Hub | |
if: env.latest_release | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# Build and push new Docker image | |
- name: Build and push new Docker image | |
if: env.latest_release | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ secrets.DOCKER_HUB_USERNAME }}/spoofdpi:${{ env.latest_release }} | |
${{ secrets.DOCKER_HUB_USERNAME }}/spoofdpi:main | |
platforms: linux/amd64 |