Ruby updates (#399) #32
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: Build docker image | |
on: | |
# schedule: | |
# - cron: '0 0 */3 * *' # @at 0h0m0s every 3 days | |
release: | |
types: [created] | |
push: | |
branches: [master, main] | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
# | |
- name: Prepare | |
id: prep | |
run: | | |
if [[ $GITHUB_EVENT_NAME == schedule ]]; then | |
sudo apt-get update -y | |
sudo apt-get install -y curl jq | |
LATEST_TAG=$(curl -sSL https://api.github.com/repos/mersea/mersea/releases/latest | jq -r .tag_name) | |
git checkout $LATEST_TAG | |
export GITHUB_REF=refs/tags/$LATEST_TAG | |
fi | |
# | |
# | |
# | |
DOCKER_IMAGE=mersea/mersea | |
VERSION=edge | |
if [[ $GITHUB_REF == refs/heads/* ]]; then | |
# Branch name | |
VERSION=${GITHUB_REF#refs/heads/} | |
fi | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
# Tag name | |
VERSION=${GITHUB_REF#refs/tags/} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:latest" | |
fi | |
echo ::set-output name=tags::${TAGS} | |
# | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
# | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
# | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
file: Dockerfile | |
context: . | |
push: true | |
tags: ${{ steps.prep.outputs.tags }} |