Skip to content

Publish Docker image #25595

Publish Docker image

Publish Docker image #25595

name: Publish Docker image
on:
push:
branches:
- main
schedule:
- cron: 37 * * * *
workflow_dispatch: {}
env:
dockerhub_tag: pahud/gitpod-workspace:latest
ghcr_tag: ghcr.io/pahud/gitpod-workspace:latest
jobs:
docker_hub:
name: Docker Hub
runs-on: ubuntu-latest
permissions:
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
contents: read
steps:
- name: Get short SHA
id: sha
# run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
# run: echo "{sha7}={$(echo ${GITHUB_SHA} | cut -c1-7)}" >> $GITHUB_OUTPUT
run: echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
# env:
# GITHUB_SHA: ${{ github.sha }} # Access the SHA from the environment
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
file: .gitpod.Dockerfile
tags: |
${{github.repository}}:latest
${{github.repository}}:${{ steps.sha.outputs.sha7 }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# github_container:
# name: Github Container Registry
# runs-on: ubuntu-latest
# steps:
# - name: Get short SHA
# id: sha
# run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.CR_PAT }}
# - name: Build and push
# id: docker_build
# uses: docker/build-push-action@v5
# with:
# push: true
# file: .gitpod.Dockerfile
# tags: |
# ghcr.io/${{github.repository}}:latest
# ghcr.io/${{github.repository}}:${{ steps.sha.outputs.sha7 }}
# - name: Image digest
# run: echo ${{ steps.docker_build.outputs.digest }}
ecr_public:
name: ECR Public
runs-on: ubuntu-latest
permissions:
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
contents: read
steps:
- name: Get repo name
id: repoName
# run: echo "::set-output name=reponame::$(echo ${{github.repository}} | cut -d '/' -f 2)"
run: echo "reponame=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT
- name: Get short SHA
id: sha
# run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
run: echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Build and Push to ECR Public
id: build-and-push
uses: pahud/ecr-public-action@ca53da9235f82d0f3aa64079540a1e7885ad47d1
with:
dockerfile: .gitpod.Dockerfile
tags: |
public.ecr.aws/pahudnet/${{ steps.repoName.outputs.reponame }}:latest
public.ecr.aws/pahudnet/${{ steps.repoName.outputs.reponame }}:${{ steps.sha.outputs.sha7 }}