-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 2.24 KB
/
build-push-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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/checkout@v3
- name: Set Timezone
uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "America/Chicago"
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.0.0
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/setup-buildx-action@v2.0.0
- name: Build and push Docker images
uses: docker/build-push-action@v3.1.1
with:
build-args: BUILD_DATE=${{ env.BUILD_DATE }}
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: cubeworx/cbwxproxy:${{ env.IMG_VER }},cubeworx/cbwxproxy:latest
- uses: ethomson/send-tweet-action@v1.0.0
if: github.event_name != 'pull_request'
with:
status: "New version of #CubeWorx #Minecraft Server Proxy Image released: https://hub.docker.com/r/cubeworx/cbwxproxy/tags?page=1&ordering=last_updated&name=${{ env.IMG_VER }} #selfhosted"
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 }}