Skip to content

Commit

Permalink
Merge pull request #3 from FrankMaverick/patch-1
Browse files Browse the repository at this point in the history
Update docker-image.yml
  • Loading branch information
ndc-istat authored Aug 26, 2024
2 parents 3d192a6 + 240263f commit 57464e1
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ on:
env:
GITHUB_WORKFLOW: dati-semantic-wordpress
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: ${{ github.repository }}

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
Expand All @@ -25,7 +22,7 @@ jobs:
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
docker build . --file Dockerfile --tag ${IMAGE}:${TAG}
deploy:
publish:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
Expand All @@ -36,12 +33,42 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: extract image
id: extractImage

- 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 and push Docker image
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
echo "##[set-output name=imageName;]${IMAGE}:${TAG}"
docker build . --file Dockerfile --tag ${IMAGE}:${TAG}
docker push ${IMAGE}:${TAG}
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'
permissions:
contents: read
packages: write
needs:
- publish
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Deploy using extracted image
run: |
echo "Deploying image: ${{ env.imageName }}"
- uses: convictional/[email protected]
with:
owner: teamdigitale
Expand All @@ -50,4 +77,4 @@ jobs:
workflow_file_name: update-config.yaml
ref: dev
wait_interval: 20
inputs: '{"serviceName": "dati-semantic-wordpress", "imageWithNewTag": "${{ steps.extractImage.outputs.imageName }}"}'
inputs: '{"serviceName": "dati-semantic-wordpress", "imageWithNewTag": "${{ env.imageName }}"}'

0 comments on commit 57464e1

Please sign in to comment.