feat: init (#1) #4
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: Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
packages: write | |
contents: write | |
pull-requests: write | |
issues: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Github Release | |
id: release | |
uses: ahmadnassri/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Docker tags | |
id: set_tags | |
run: | | |
if [ "${{ steps.release.outputs.release-version }}" != "" ]; then | |
echo "TAGS=type=raw,value=latest,type=sha,type=semver,pattern={{version}},value=${{ steps.release.outputs.release-version }}" >> $GITHUB_ENV | |
else | |
echo "TAGS=type=raw,value=latest,type=sha" >> $GITHUB_ENV | |
fi | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/hutchic-org/${{ github.event.repository.name }} | |
tags: ${{ env.TAGS }} | |
- name: Build and Push Docker image | |
if: ${{ steps.release.outputs.release-version != '' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha,ref=ghcr.io/hutchic-org/${{ github.event.repository.name }} | |
cache-to: type=gha,mode=max |