Merge pull request #52 from andy000923/master #42
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: "[Push] Build Dev" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
DOCKER_ORGANIZATION: ${{ secrets.DOCKER_ORGANIZATION || 'cloudforet' }} | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
jobs: | |
versioning: | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository_owner != 'cloudforet-io') | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.versioning.outputs.VERSION }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: get current date | |
run: | | |
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime | |
echo "TIME=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV | |
- name: set version with current date | |
id: versioning | |
run: | | |
echo "VERSION=$(sed 's/v//' < src/VERSION).${{ env.TIME }}" >> $GITHUB_OUTPUT | |
- name: Notice when job fails | |
if: failure() && github.repository_owner == 'cloudforet-io' | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
status: ${{ job.status }} | |
title: "Workflow Failed" | |
description: "The ${{ github.workflow }} workflow in ${{ github.repository }} has failed." | |
username: GitHub Action Discord Notification | |
docker: | |
needs: versioning | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.versioning.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- 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: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build and push to dockerhub | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.DOCKER_ORGANIZATION }}/${{ github.event.repository.name }}:${{ env.VERSION }} | |
file: ./Dockerfile | |
- name: Notice when job fails | |
if: failure() && github.repository_owner == 'cloudforet-io' | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
status: ${{ job.status }} | |
title: "Workflow Failed" | |
description: "The ${{ github.workflow }} workflow in ${{ github.repository }} has failed." | |
username: GitHub Action Discord Notification | |
notification: | |
runs-on: ubuntu-latest | |
needs: docker | |
steps: | |
- name: Discord | |
if: always() && github.repository_owner == 'cloudforet-io' | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
status: ${{ job.status }} | |
title: "Workflow ${{ job.status }} Completed" | |
description: | | |
**Repository:** ${{ github.repository }} | |
**Commit Message:** ${{ github.event.head_commit.message }} | |
**Commit:** ${{ github.sha }} | |
**Author:** ${{ github.actor }} | |
**Action:** ${{ github.event_name }} | |
**Ref:** ${{ github.ref }} | |
**Workflow:** ${{ github.workflow }} | |
**Job:** ${{ job.job }} | |
username: GitHub Action Discord Notification |