Build, Push, and Export Backend Docker Image #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Push, and Export Backend Docker Image | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
build-push-export-backend: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# Log in to GitHub Container Registry | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Build and push the Docker image | |
- name: Build and Push Docker Image | |
working-directory: ./backend | |
env: | |
VERSION: ${{ github.event.release.tag_name }} | |
run: | | |
# Build the Docker image | |
docker build -t ghcr.io/ikapiar/backend:${VERSION} . | |
# Push the Docker image | |
docker push ghcr.io/ikapiar/backend:${VERSION} | |
# Export the Docker image to an OCI-compatible tarball | |
- name: Export Docker Image | |
working-directory: ./backend | |
env: | |
VERSION: ${{ github.event.release.tag_name }} | |
run: | | |
# Save the Docker image as a tar file with the new naming format | |
docker save ghcr.io/ikapiar/backend:${VERSION} | gzip > ikapiar-backend_${VERSION}.tar.gz | |
# Upload the tarball to the release assets | |
- name: Upload Exported Image to Release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./backend/ikapiar-backend_${VERSION}.tar.gz | |
asset_name: ikapiar-backend_${VERSION}.tar.gz | |
asset_content_type: application/gzip |