Optimize dockerfile #12
Workflow file for this run
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 to ghcr.io | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
jobs: | |
build_and_push: | |
name: Build and push | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set Build Timestamp | |
run: echo "BUILD_TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S:%z')" >> $GITHUB_ENV | |
- name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
env: | |
BUILD_BRANCH: ${{ github.head_ref || github.ref_name }} | |
with: | |
context: . | |
target: app | |
push: true | |
build-args: | | |
BUILD_BRANCH=${{ env.BUILD_BRANCH }} | |
BUILD_COMMIT=${{ github.sha }} | |
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }} | |
tags: | | |
ghcr.io/${{ github.repository }}:latest | |
ghcr.io/${{ github.repository }}:${{ env.BUILD_BRANCH }} |