Skip to content

Commit

Permalink
added test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Sep 29, 2023
1 parent c6dc3c8 commit de9e8f2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
79 changes: 53 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
IMAGE_NAME: action
REGISTRY: ghcr.io

jobs:
test-image:
Expand Down Expand Up @@ -53,7 +54,8 @@ jobs:

tag:
if: github.event_name == 'push' && needs.test-versions.outputs.version != ''
needs: [test-image, test-versions]
# needs: [test-image, test-versions]
needs: [test-versions]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -71,34 +73,59 @@ jobs:
env:
VERSION: ${{ needs.test-versions.outputs.version }}
GH_TOKEN: ${{ github.token }}

publish:
runs-on: ubuntu-latest
permissions:
packages: write
needs: [tag, test-versions]
if: needs.tag.outputs.tagExists == 'false'
# !Undo this
needs: [test-versions]
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build . --file Dockerfile --label "version=$TAG" --tag $IMAGE_NAME
env:
TAG: v${{ needs.test-versions.outputs.version }}
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//')
# Use 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
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
- run: echo "Tags are $tags and labels are $labels"
env:
TAG: v${{ needs.test-versions.outputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- uses: actions/checkout@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# - uses: actions/checkout@v3
# - name: Build image
# run: docker build . --file Dockerfile --label "version=$TAG" --tag $IMAGE_NAME
# env:
# TAG: v${{ needs.test-versions.outputs.version }}
# - name: Log into registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
# - name: Push image
# run: |
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# # Change all uppercase to lowercase
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# # Strip git ref prefix from version
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# # Strip "v" prefix from tag name
# [[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//')
# # Use 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
# env:
# TAG: v${{ needs.test-versions.outputs.version }}
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN yarn run build

FROM node:18-slim

LABEL mantainer="Javier Bullrich <[email protected]>"

COPY --from=Builder /action/dist /action

ENTRYPOINT ["node", "/action/index.js"]

0 comments on commit de9e8f2

Please sign in to comment.