Skip to content

Commit

Permalink
replace VERSION and PROJECT with github-env-vars-action provided vari…
Browse files Browse the repository at this point in the history
…ables
  • Loading branch information
paul-gilber committed Nov 4, 2023
1 parent 40ae6e0 commit cd613d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 31 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/code-scan-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,8 @@ jobs:
pull-requests: read # Allow SonarCloud to get pull request details
environment: sonarcloud # Use `sonarcloud` repository environment
steps:
# Workaround for the absence of github.branch_name
# Setting an environment variable: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set VERSION
if: github.head_ref != ''
run: |
echo "VERSION=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Set VERSION
if: github.head_ref == ''
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
# Workaround for the absence of github.branch_name, use github-env-vars-action to define useful environment variables not available by default
- uses: FranzDiebold/github-env-vars-action@v2 # https://github.com/marketplace/actions/github-environment-variables-action

- name: Checkout repository
uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
Expand Down Expand Up @@ -91,7 +83,7 @@ jobs:
# run: |
# mvn -B verify \
# org.sonarsource.scanner.npm:sonar-npm-plugin:sonar \
# -Drevision=${{ env.VERSION }} \
# -Drevision=${{ env.CI_ACTION_REF_NAME }} \
# -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} \
# -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
# -Dmaven.test.skip=true \
Expand All @@ -111,7 +103,7 @@ jobs:
# run: |
# mvn -B verify \
# org.sonarsource.scanner.npm:sonar-npm-plugin:sonar \
# -Drevision=${{ env.VERSION }} \
# -Drevision=${{ env.CI_ACTION_REF_NAME }} \
# -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} \
# -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
# -Dsonar.pullrequest.provider=GitHub \
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/merge-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ on:
# Set Workflow-level permissions: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions: {} # This Workflow does not require any permission

# Set Workflow-level environment variables
env:
PROJECT: demoapp-frontend

jobs:
output-information:
runs-on: ubuntu-latest
Expand All @@ -45,23 +41,20 @@ jobs:
# - name: Skopeo Delete Image
# id: skopeo-delete
# run: |
# skopeo delete docker://${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}:${{ env.VERSION }}
# skopeo delete docker://${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}

# Regctl allows image tag deletion which is allowed by Docker Hub
docker-hub-regctl:
runs-on: ubuntu-latest
environment: docker-hub
steps:
# Workaround for the absence of github.branch_name
# Setting an environment variable: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set VERSION
if: github.head_ref != ''
run: |
echo "VERSION=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Set VERSION
if: github.head_ref == ''
# Workaround for the absence of github.branch_name, use github-env-vars-action to define useful environment variables not available by default
- uses: FranzDiebold/github-env-vars-action@v2 # https://github.com/marketplace/actions/github-environment-variables-action

# Set Complete Container Image URL
- name: Set CONTAINER_IMAGE_URL
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV
# Install regctl: https://github.com/regclient/regclient
- name: Install regctl
Expand All @@ -75,4 +68,4 @@ jobs:
--pass ${{ secrets.DOCKER_REGISTRY_PASSWORD }} \
- name: regctl Delete Image Tag
run: |
./regctl tag delete ${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}:${{ env.VERSION }}
./regctl tag delete ${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
tags:
- 'v*' # When a tag starting with `v` is created e.g. v1.0.0

# Set Workflow-level environment variables
env:
PROJECT: demoapp-frontend

jobs:
push_to_registries:
name: Push Container image to multiple registries
Expand Down

0 comments on commit cd613d2

Please sign in to comment.