Check if image exist instead of doesnt exist #12
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
on: | |
push: | |
branches: | |
- "ekw/SRE-1004/release-base-image" | |
env: | |
RUST_VERSION: "1.73.0" | |
GHC_VERSION: "9.6.4" | |
IMAGE_TAG: rust1.73-ghc9.6.4 | |
jobs: | |
release-base-image: | |
runs-on: ubuntu-latest | |
environment: release | |
env: | |
IMAGE_NAME: "concordium/base" | |
DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} | |
DOCKERHUB_TOKEN: ${{secrets.DOCKERHUB_TOKEN}} | |
steps: | |
- name: Check if image exist | |
run: | | |
set +e | |
docker manifest inspect ${{env.IMAGE_NAME}}:${{env.IMAGE_TAG}} | |
exitcode=$? | |
if [ $exitcode -eq "0" ]; then | |
echo "Error: ${{env.IMAGE_NAME}}:rust${{env.RUST_VERSION}}-ghc${{env.GHC_VERSION}} already exist" | |
exit 1 | |
fi | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ env.DOCKERHUB_TOKEN }} | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: build docker image | |
run: | | |
docker build --build-arg rust_version="${{env.RUST_VERSION}}" --build-arg ghc_version="${{env.GHC_VERSION}}" --label rust_version="${{env.RUST_VERSION}}" --label ghc_version="${{env.GHC_VERSION}}" -f "docker/base.Dockerfile" -t "${{env.IMAGE_NAME}}:${{env.IMAGE_TAG}}" . | |
- name: Push docker image | |
run: | | |
echo ${{env.IMAGE_NAME}}:${{env.IMAGE_TAG}} |