Dockerhub #69
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: Dockerhub | |
on: workflow_dispatch | |
jobs: | |
dockerhub-build: | |
runs-on: self-hosted | |
steps: | |
- name: 'Cleanup build folder' | |
run: | | |
ls -la ./ | |
rm -rf ./* || true | |
rm -rf ./.??* || true | |
ls -la ./ | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Commit Hash | |
id: vars | |
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Add "VERSION" hashes to .env | |
run: echo -e "VERSION=${{ steps.vars.outputs.sha }}\nVITE_VERSION=${{ steps.vars.outputs.sha }}" >> .env.example | |
- name: Copy environment file and set version | |
run: cp .env.example .env | |
- name: Login to DockerHub | |
run: docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Docker Image | |
run: docker buildx build -t ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:${{ steps.vars.outputs.sha }} -t ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:latest . | |
- name: Push Docker Image | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:${{ steps.vars.outputs.sha }} && docker push ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:latest | |
- name: Clean up Docker | |
run: docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:latest && docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/pgetinker:${{ steps.vars.outputs.sha }} | |
- name: Logout of DockerHub | |
run: docker logout |