Merge pull request #2 from dev-launchers/chungthuang/issue-1 #1
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: staging-image | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
# Ignore when changes is made by flux | |
- 'staging/**' | |
- 'production/**' | |
# Ignore markdown files | |
- "**/*.md" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# https://stackoverflow.com/questions/60942067/get-current-date-and-time-in-github-workflows | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M')" | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
# list of Docker images to use as base name for tags | |
images: devlaunchers/onboardingbot # list of Docker images to use as base name for tags | |
# generate Docker tags based on the following events/attributes | |
# flux image update policy sorts by timestamp | |
tags: | | |
type=raw,value={{sha}}-${{ steps.date.outputs.date }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/#-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |