Skip to content

Commit

Permalink
Merge pull request #7 from jaronoff97/fix-gh-action
Browse files Browse the repository at this point in the history
fix gh action
  • Loading branch information
jaronoff97 authored Apr 4, 2024
2 parents 6cbf066 + bdd5fb7 commit b2b2fd0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/create-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Generate Tag"

on:
workflow_dispatch:
inputs:
version:
description: "Tag Version x.x.x"
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ github.event.inputs.version }}',
sha: context.sha
})
40 changes: 39 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name: Create and publish a Docker image
on:
push:
branches: ["main"]

tags:
- "v*"
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -38,6 +39,12 @@ jobs:
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{raw}}
type=ref,event=branch
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand All @@ -48,3 +55,34 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
needs: build-and-push-image
name: "Release"
if: github.ref_type == 'tag'
runs-on: "ubuntu-latest"

steps:
- name: "Determine tag"
run: 'echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV'

- name: "Create release"
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN mix local.hex --force && \

# set build ENV
ENV MIX_ENV="prod"
ENV ERL_AFLAGS="+JPperf true"

# install mix dependencies
COPY mix.exs mix.lock ./
Expand Down

0 comments on commit b2b2fd0

Please sign in to comment.