Skip to content

Commit

Permalink
fix(): modified yaml to use compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Christiantyemele committed Dec 6, 2024
1 parent a8a11e0 commit f299970
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Create and publish a Docker image

on:
Expand All @@ -10,42 +9,50 @@ on:
pull_request:

env:
IMAGE_NAME: ${{ github.repository }}
#
jobs:
IMAGE_NAME: ghcr.io/adorsys/didcomm-mediator-rs

jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
#

steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build image
run: docker-compose build --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Log in to registry
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
#
- name: Push image

- name: Build Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
echo "Checking for .env file..."
if [ -f .env ]; then
echo ".env file exists."
else
echo ".env file does not exist."
exit 1
fi
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/heads/main" ]] && VERSION=latest
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo "Building image with version: $VERSION"
docker-compose build
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${VERSION}
- name: Push Docker image
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/heads/main" ]] && VERSION=latest
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "Pushing image ${IMAGE_NAME}:${VERSION}"
docker push ${IMAGE_NAME}:${VERSION}

0 comments on commit f299970

Please sign in to comment.