Skip to content

Commit

Permalink
Tag update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyeremeh committed Feb 3, 2023
1 parent 3ff245c commit 2de3d38
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
run: bash scripts/build.sh
16 changes: 16 additions & 0 deletions .github/workflows/update-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Update Image Tag
on:
# schedule:
# - cron: "29 10 1,5 * *"
push:
branches: ["master"]

jobs:
update-tag:
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout repository
uses: actions/checkout@v3

- run: bash scripts/update_tag.sh
4 changes: 1 addition & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ their_version=$(get_latest_release vercel/serve)
our_version=$(get_tag)

if [ "$their_version" \> "$our_version" ]; then
git tag $their_version
git push
build_images eldekyfin/serve $their_version
build_n_push eldekyfin/serve $their_version
else
echo "Already up to date. No need to rebuild"
fi
19 changes: 19 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

function get_latest_release {
wget -q https://api.github.com/repos/$1/releases/latest -O - | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}

function get_tag {
git tag | tail -n 1
}

function build_n_push {
docker buildx build . \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--tag $1:$2 \
--tag $1:latest \
--push
}
15 changes: 15 additions & 0 deletions scripts/update_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
dir=$(dirname $0)

source $dir/functions.sh

their_version=$(get_latest_release vercel/serve)
our_version=$(get_tag)

if [ "$their_version" \> "$our_version" ]; then
git tag $their_version
git push origin $their_version
build_n_push eldekyfin/serve $their_version
else
echo Image is recent. Nothing to do...
fi

0 comments on commit 2de3d38

Please sign in to comment.