Merge pull request #23 from t1nyb0x/develop #2
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: | |
push: | |
branches: | |
- main | |
release: | |
types: [published] | |
env: | |
DOCKER_BASE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
hadolint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- uses: hadolint/hadolint-action@v3.1.0 | |
with: | |
dockerfile: Dockerfile | |
push-image: | |
runs-on: ubuntu-latest | |
needs: hadolint | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Env | |
run: | | |
if [ "${{ github.event_name }}" = 'release' ]; then | |
export TAG_NAME="${{ github.event.release.tag_name }}" | |
else | |
export TAG_NAME="latest" | |
fi | |
echo "PKG_TAG"=${DOCKER_BASE_NAME}:${TAG_NAME} >> ${GITHUB_ENV} | |
- name: Build Image | |
run: | | |
docker build . -t "${PKG_TAG}" | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push Image | |
run: | | |
docker push "${PKG_TAG}" |