Merge pull request #1 from StarTrooper08/remove-slimtoolkit #26
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: Build, Optimize and Publish Docker Image to Github Registry | |
on: | |
push: | |
branches: ['main'] | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout Github Repo | |
uses: actions/checkout@v3 | |
- name: Set version number from release | |
if: ${{ github.event_name == 'release' }} | |
run: | | |
echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
- name: Log in to Github Image Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
CONTAINER_VERSION=${{ env.VERSION }} | |
labels: ${{ steps.meta.outputs.tags }} | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASS }} | |
- name: Build Image | |
shell: bash | |
run: docker build . -t atharvas08/hashcraft:latest | |
- name: Docker Push | |
shell: bash | |
run: docker push atharvas08/hashcraft:latest | |