|
| 1 | +name: Upload latest to DockerHub |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Set up QEMU |
| 15 | + uses: docker/setup-qemu-action@v3 |
| 16 | + |
| 17 | + - name: Install GitVersion |
| 18 | + uses: gittools/actions/gitversion/[email protected] |
| 19 | + with: |
| 20 | + versionSpec: '5.x' |
| 21 | + |
| 22 | + - name: Install Checkout |
| 23 | + |
| 24 | + with: |
| 25 | + ref: ${{ github.head_ref }} # checkout the correct branch name |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Determine Version |
| 29 | + id: gitversion # id to later be referenced |
| 30 | + uses: gittools/actions/gitversion/[email protected] |
| 31 | + with: |
| 32 | + additionalArguments: /config commit-date-format="yyyy-MM-ddTHH:mm:ss-0000" |
| 33 | + |
| 34 | + - name: Alternate Git Version |
| 35 | + id: alternategitversion |
| 36 | + |
| 37 | + with: |
| 38 | + release-branch: 'main' |
| 39 | + prefix: 'v' |
| 40 | + |
| 41 | + - name: Direct Git Version |
| 42 | + id: directgitversion |
| 43 | + run: | |
| 44 | + GITDIRECTVERSION=`git describe --tags --dirty` |
| 45 | + echo "GITDIRECTVERSION=${GITDIRECTVERSION}" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - name: Display GitVersion outputs (step output) |
| 48 | + run: | |
| 49 | + GITSHA=${{ steps.gitversion.outputs.Sha }} |
| 50 | + GITSHA8=${GITSHA:0:8} |
| 51 | + GITCOMMITS=${{ steps.gitversion.outputs.CommitsSinceVersionSource }} |
| 52 | + GITPREVVERSION=${{ steps.alternategitversion.outputs.previous-version }} |
| 53 | + GITVERSION=${GITPREVVERSION}+${GITCOMMITS}.g${GITSHA8} |
| 54 | + GITTIME=`git show | grep Date | head -n 1 | awk '{print $5 $7}'` |
| 55 | + GITDATE=${{ steps.gitversion.outputs.commitDate }}"T"${GITTIME} |
| 56 | + echo "GITVERSION=${GITVERSION}" >> $GITHUB_ENV |
| 57 | + echo "GITSHA=${GITSHA}" >> $GITHUB_ENV |
| 58 | + echo "GITDATE=${GITDATE}" >> $GITHUB_ENV |
| 59 | + BUILD_TIME=$(date -Iseconds) |
| 60 | + echo "BUILD_TIME=${BUILD_TIME}" >> $GITHUB_ENV |
| 61 | +
|
| 62 | + - name: What |
| 63 | + run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 64 | + |
| 65 | + - name: Set up Docker Buildx |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Login to DockerHub |
| 69 | + uses: docker/login-action@v3 |
| 70 | + with: |
| 71 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 72 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Get version number |
| 75 | + id: get_version |
| 76 | + run: echo "VERSION=${{ github.ref }}" >> $GITHUB_OUTPUT |
| 77 | + |
| 78 | + - name: Free disk space |
| 79 | + run: | |
| 80 | + df -h |
| 81 | + sudo rm -rf ${GITHUB_WORKSPACE}/.git |
| 82 | + sudo swapoff -a |
| 83 | + sudo rm -f /swapfile |
| 84 | + sudo apt clean |
| 85 | + sudo rm -rf /usr/share/dotnet |
| 86 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 87 | + df -h |
| 88 | +
|
| 89 | + - name: Build and push |
| 90 | + id: docker_build |
| 91 | + uses: docker/build-push-action@v6 |
| 92 | + with: |
| 93 | + platforms: linux/amd64,linux/arm64 |
| 94 | + push: true |
| 95 | + sbom: true |
| 96 | + provenance: true |
| 97 | + cache-from: type=gha |
| 98 | + cache-to: type=gha,mode=max |
| 99 | + tags: fredericklab/stabilitycalc:latest |
| 100 | + build-args: | |
| 101 | + BRANCH=${{ env.BRANCH }} |
| 102 | + GITVERSION=${{ env.GITVERSION }} |
| 103 | + GITSHA=${{ env.GITSHA }} |
| 104 | + GITDATE=${{ env.GITDATE }} |
| 105 | + BUILD_TIME=${{ env.BUILD_TIME }} |
0 commit comments