Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker-image.yml #4

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@ env:
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
docker build . --file Dockerfile --tag ${IMAGE}:${TAG}
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the GitHub Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker image
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
docker build . --file Dockerfile --tag ${IMAGE}:${TAG}
docker push ${IMAGE}:${TAG}
docker tag ${IMAGE}:${TAG} ${IMAGE}:latest
docker push ${IMAGE}:latest

publish:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,10 +66,6 @@ jobs:
docker tag ${IMAGE}:${TAG} ${IMAGE}:latest
docker push ${IMAGE}:latest

- name: Output image name
id: extractImage
run: echo "imageName=${IMAGE}:${TAG}" >> $GITHUB_ENV

deploy:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
Expand All @@ -67,8 +79,11 @@ jobs:
uses: actions/checkout@v2

- name: Deploy using extracted image
id: extractImage
run: |
echo "Deploying image: ${{ env.imageName }}"
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
echo "##[set-output name=imageName;]${IMAGE}:${TAG}"
- uses: convictional/[email protected]
with:
owner: teamdigitale
Expand All @@ -77,4 +92,4 @@ jobs:
workflow_file_name: update-config.yaml
ref: dev
wait_interval: 20
inputs: '{"serviceName": "dati-semantic-wordpress", "imageWithNewTag": "${{ env.imageName }}"}'
inputs: '{"serviceName": "dati-semantic-wordpress", "imageWithNewTag": "${{ steps.extractImage.outputs.imageName }}"}'