Skip to content

Commit

Permalink
fix: artifacts and tagging variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rilesdun committed Sep 25, 2023
1 parent 2eb00a5 commit a7b14ac
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ jobs:
- name: Get the latest tag
id: get-latest-tag
run: |
echo "$(git tag --sort=taggerdate | tail -1)" > tag.txt
TAG=$(git tag --sort=taggerdate | tail -1)
echo "tag=${TAG}" >> $GITHUB_ENV
echo "${TAG}" > "tag-${TAG}.txt"
- name: Upload tag as artifact
uses: actions/upload-artifact@v2
- name: Upload tag file
uses: actions/upload-artifact@v3.1.3
with:
name: latest-tag
path: ./tag.txt
name: tag-file
path: "tag-${{ env.tag }}.txt"

- name: Log into Docker Hub
uses: docker/login-action@v3.0.0
Expand All @@ -134,13 +136,12 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0

# Extract metadata (tags, labels)
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=semver,pattern={{version}}
tags: ${{ env.tag }}

- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
Expand All @@ -155,7 +156,6 @@ jobs:
- name: Log out from Docker Hub
run: docker logout ${{ env.REGISTRY }}


deploy:
runs-on: ubuntu-latest
needs: [dockerhub_publish]
Expand All @@ -167,22 +167,22 @@ jobs:
echo "$PRIVATE_KEY" > deploy_key
chmod 600 deploy_key
- name: Download tag from artifact
uses: actions/download-artifact@v2
- name: Download tag file
uses: actions/download-artifact@v3.0.2
with:
name: latest-tag
- name: Set tag as env variable
run: echo "TAG=$(cat tag.txt)" >> $GITHUB_ENV

- name: Print the latest tag
run: echo "The latest tag is ${{ env.TAG }}"
name: tag-file

- name: Read tag from file
id: read-tag
run: |
TAG=$(cat tag-*.txt)
echo "tag=${TAG}" >> $GITHUB_ENV
- name: Deploy on VM
run: |
ssh -o StrictHostKeyChecking=no -i deploy_key ${{ secrets.VM_USER }}@${{ secrets.VM_IP }} << ENDSSH
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}
docker stop explorer-api || true
docker rm explorer-api || true
docker run -d --name explorer-api ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
ENDSSH
docker run -d --name explorer-api ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}
ENDSSH

0 comments on commit a7b14ac

Please sign in to comment.