Skip to content

public image

public image #12

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-it:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint Dockerfile with Hadolint
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up variables
id: vars
run: |
echo "REPO_OWNER=${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_OUTPUT
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_OUTPUT
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ghcr.io/${{ steps.vars.outputs.REPO_OWNER }}/${{ steps.vars.outputs.REPO_NAME }}:latest
- name: Push the Docker image
run: docker push ghcr.io/${{ steps.vars.outputs.REPO_OWNER }}/${{ steps.vars.outputs.REPO_NAME }}:latest
- name: Make Docker image public
run: |
curl -X PATCH \
-H "Authorization: Bearer ${{ secrets.GHCR_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/container/${{ steps.vars.outputs.REPO_NAME }}/visibility \
-d '{"visibility":"public"}'