Add the drive firmware update script used in manufacturing #299
Workflow file for this run
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: Docker build and push | |
on: [push] | |
env: | |
# TEST_TARGET: Name of the testing target in the Dockerfile | |
TEST_TARGET: container-unit-test | |
# DO_TEST - true to build and run unit tests, false to skip the tests | |
DO_TEST: true | |
# DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push | |
DO_PUSH: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lowercase repository name for docker build | |
id: lowercase-repository-name | |
run: | | |
echo "HPE_BUILD_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
echo "HPE_DEPLOY_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: set TAG & TESTTAG for main/master | |
if: ${{ github.event.repository.default_branch == 'main' || github.event.repository.default_branch == 'master' }} | |
run: | | |
echo "TAG=${{ github.sha }}" >> ${GITHUB_ENV} | |
echo "LATESTTAG=latest" >> ${GITHUB_ENV} | |
echo "TESTTAG=test-${{ github.sha }}" >> ${GITHUB_ENV} | |
- name: set TAG & TESTTAG for all other branches | |
if: ${{ github.event.repository.default_branch != 'main' && github.event.repository.default_branch != 'master' }} | |
run: | | |
echo "TAG=dev-${{ github.sha }}" >> ${GITHUB_ENV} | |
echo "LATESTTAG=dev-latest" >> ${GITHUB_ENV} | |
echo "TESTTAG=test-${{ github.sha }}" >> ${GITHUB_ENV} | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the test Docker image | |
if: ${{ env.DO_TEST == 'true' }} | |
id: docker_build_test_target | |
uses: docker/build-push-action@v5 | |
with: | |
push: false | |
target: ${{ env.TEST_TARGET }} | |
tags: ${{ env.HPE_BUILD_REPO }}:${{ env.TESTTAG }} | |
secrets: | | |
"GH_HPETOKEN=${{ secrets.GH_HPETOKEN }}" | |
- name: Run the Docker image unit tests | |
if: ${{ env.DO_TEST == 'true' }} | |
run: docker run ${HPE_BUILD_REPO}:${TESTTAG} | |
- name: Build the final Docker image | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
push: false | |
tags: ${{ env.HPE_BUILD_REPO }}:${{ env.TAG }} | |
secrets: | | |
"GH_HPETOKEN=${{ secrets.GH_HPETOKEN }}" | |
- name: Tag the build | |
run: docker tag docker.io/${HPE_BUILD_REPO}:${TAG} ghcr.io/${HPE_DEPLOY_REPO}:${TAG} | |
- name: Tag the build as latest | |
run: docker tag ${HPE_BUILD_REPO}:${TAG} ghcr.io/${HPE_DEPLOY_REPO}:${LATESTTAG} | |
- name: Push the tagged build | |
if: ${{ env.DO_PUSH == 'true' }} | |
run: docker push ghcr.io/${HPE_DEPLOY_REPO}:${TAG} | |
- name: Push the build tagged as latest | |
if: ${{ env.DO_PUSH == 'true' }} | |
run: docker push ghcr.io/${HPE_DEPLOY_REPO}:${LATESTTAG} | |
create_release: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Repair tag | |
run: git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
- name: Verify that the tag is annotated | |
run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
#prerelease: true | |
generate_release_notes: true | |