Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
update publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylmendillo committed Mar 31, 2021
1 parent 5beb886 commit 22b2f33
Showing 1 changed file with 5 additions and 55 deletions.
60 changes: 5 additions & 55 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,10 @@ jobs:
steps:
- name: checkout
uses: actions/[email protected]

- name: version
run: |
# Tagged release
if [[ ${{ github.ref }} == refs/tags/* ]]; then
# Strip git ref prefix from $VERSION
TAGNAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
VERSION=$(echo $TAGNAME | sed -e 's/^v//')
else
VERSION=${{ github.sha }}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "GITHUB_REF=$GITHUB_REF" >> $GITHUB_ENV
# write .env to export ENV VARIABLES as artifacts for use in other workflow_run runs
echo "PUBLISH_VERSION=$VERSION" >> .env
echo "PUBLISH_GITHUB_REF=$GITHUB_REF" >> .env
echo "Version: $VERSION"
export DOCKER_BUILDKIT=1

- name: publish
run: |
VERSION="${{ env.VERSION }}"
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
# build and run the docker images
docker-compose -f docker-compose.build.yml up --no-start
# get all built IDs
IMAGE_IDs=$(docker-compose -f docker-compose.build.yml images -q)
echo "IMAGE_IDs: $IMAGE_IDs"
while read -r IMAGE_ID; do
echo "IMAGE_ID: $IMAGE_ID"
# get the name label
NAME=$(basename ${{ github.repository }}).$(docker inspect --format '{{ index .Config.Labels.name }}' $IMAGE_ID)
PUSH="docker.pkg.github.com/${{ github.repository }}/$NAME:$VERSION"
# tag and push
docker tag $IMAGE_ID $PUSH
docker push $PUSH
done <<< "$IMAGE_IDs"
# Upload reference as artifact to pass to deploy
- name: upload .env
uses: actions/upload-artifact@v2
id: publish
uses: pennsignals/[email protected]
with:
name: env
path: .env
docker_compose: 'docker-compose.build.yml'
repo_token: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 22b2f33

Please sign in to comment.