-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (31 loc) · 1.46 KB
/
build-and-push-dockerhub.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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