Skip to content

Feature/rework

Feature/rework #4

name: build-push-docker
# Controls when the workflow will run
on:
# Triggers the workflow on push events for the master branch
push:
branches: [ master ]
paths:
- 'Dockerfile'
- '**.sh'
- '**.txt'
pull_request:
branches: [ master ]
paths:
- 'Dockerfile'
- '**.sh'
- '**.txt'
# Allows this workflow to be ran manually from the Actions tab
workflow_dispatch:
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
# Checkout repository
- uses: actions/[email protected]
- name: Set Timezone
uses: szenius/[email protected]
with:
timezoneLinux: "America/Chicago"
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Generate Version Number
run: |
eval "$(date +'today=%F now=%s')"
IMG_VER="$(date +%Y.%m.%d).$((now - $(date -d "$today 0" +%s)))"
echo "IMG_VER=${IMG_VER}" >> $GITHUB_ENV
BUILD_DATE=$(date +%Y.%m.%d)
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_ENV
- name: Docker Setup Buildx
uses: docker/[email protected]
- name: Build and push Docker images
uses: docker/[email protected]
with:
build-args: BUILD_DATE=${{ env.BUILD_DATE }}
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: cubeworx/mcje-server:${{ env.IMG_VER }},cubeworx/mcje-server:latest
- uses: ethomson/[email protected]
if: github.event_name != 'pull_request'
with:
status: "New version of CubeWorx Minecraft Java Edition Server Image released: https://hub.docker.com/r/cubeworx/mcje-server/tags?page=1&ordering=last_updated&name=${{ env.IMG_VER }}"
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}