Skip to content

Commit

Permalink
[FIX] Wrong endpoint for cronjob
Browse files Browse the repository at this point in the history
[ADD] Auto tagging new version on GitHub and DockerHub
  • Loading branch information
giuseppe99barchetta committed Oct 30, 2024
1 parent c0d891d commit 207e867
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 47 deletions.
53 changes: 49 additions & 4 deletions .github/workflows/docker_hub_build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@

name: Build and Publish Docker Image to Docker Hub
name: Bump Version, Build and Publish Docker Image

on:
push:
branches:
- main

jobs:
bump-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '20'

- name: Ensure Dependencies are Installed
run: |
npm install -g semver
sudo apt-get install jq -y
- name: Strip 'v' prefix and bump version in package.json
id: bump_version
run: |
cd client/
# Remove 'v' prefix and save temporary file
current_version=$(jq -r '.version' package.json | sed 's/^v//')
# Increment the version (adjust patch to minor/major as needed)
new_version=$(npx semver $current_version -i patch)
# Add 'v' prefix to new version
prefixed_version="v$new_version"
echo "Bumping version from v$current_version to $prefixed_version"
# Update package.json with the prefixed version
jq ".version = \"$prefixed_version\"" package.json > package_tmp.json && mv package_tmp.json package.json
# Save new version in GitHub Actions environment
echo "new_version=$prefixed_version" >> $GITHUB_ENV
- name: Commit and push new version
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add client/package.json
git commit -m "chore: bump version to ${{ env.new_version }}"
# Tag the new version with the v-prefixed format
git tag -a "${{ env.new_version }}" -m "Release ${{ env.new_version }}"
git push origin main
git push origin "${{ env.new_version }}"
build:
needs: bump-version
runs-on: ubuntu-latest

steps:
Expand All @@ -20,11 +64,12 @@ jobs:
- name: Log in to Docker Hub
run: echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ciuse99 --password-stdin

- name: Build and Push Docker Image (SuggestArr)
- name: Build and Push Docker Image
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--cache-from type=registry,ref=ciuse99/suggestarr:cache \
--cache-to type=registry,ref=ciuse99/suggestarr:cache,mode=max \
-t ciuse99/suggestarr:latest \
-f docker/Dockerfile . --push
-t ciuse99/suggestarr:${{ env.new_version }} \
-f docker/Dockerfile . --push
42 changes: 1 addition & 41 deletions .github/workflows/docker_hub_build_nightly.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,12 @@
name: Bump Version, Build and Publish Docker Image
name: Build and Publish Docker Image to Docker Hub

on:
push:
branches:
- nightly

jobs:
bump-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '16'

- name: Strip 'v' prefix and bump version in package.json
id: bump_version
run: |
cd client/
# Remove 'v' prefix and save temporary file
current_version=$(jq -r '.version' package.json | sed 's/^v//')
# Increment the version (adjust patch to minor/major as needed)
new_version=$(npx semver $current_version -i patch)
# Add 'v' prefix to new version
prefixed_version="v$new_version"
echo "Bumping version from v$current_version to $prefixed_version"
# Update package.json with the prefixed version
jq ".version = \"$prefixed_version\"" package.json > package_tmp.json && mv package_tmp.json package.json
# Save new version in GitHub Actions environment
echo "new_version=$prefixed_version" >> $GITHUB_ENV
- name: Commit and push new version
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add client/package.json
git commit -m "chore: bump version to ${{ env.new_version }}"
# Tag the new version with the v-prefixed format
git tag -a "${{ env.new_version }}" -m "Release ${{ env.new_version }}"
git push origin nightly
git push origin "${{ env.new_version }}"
build:
needs: bump-version
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion api_service/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def update_cron_job(cron_time):
"""
try:
# Command to call the Flask endpoint using curl
cron_command = "curl -X POST http://localhost:5000/force_run >> /var/log/cron.log 2>&1"
cron_command = "curl -X POST http://localhost:5000/api/automation >> /var/log/cron.log 2>&1"

# Create the cron job entry
cron_entry = f"{cron_time} {cron_command}\n"
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SuggestArr",
"version": "v1.0.10",
"version": "v1.0.9",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down

0 comments on commit 207e867

Please sign in to comment.