Skip to content

Commit be0358f

Browse files
committed
Add action to push to docker hub
1 parent 56fc7a3 commit be0358f

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
schedule:
10+
- cron: "43 14 * * *"
11+
push:
12+
branches: [main]
13+
# Publish semver tags as releases.
14+
tags: ["v*.*.*"]
15+
pull_request:
16+
branches: [main]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: docker.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: cblauvelt/vscode-cpp
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v2
34+
35+
# Login against a Docker registry except on PR
36+
# https://github.com/docker/login-action
37+
- name: Log into registry ${{ env.REGISTRY }}
38+
if: github.event_name != 'pull_request'
39+
uses: docker/login-action@v1
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ secrets.DOCKERHUB_USERNAME }}
43+
password: ${{ secrets.DOCKERHUB_TOKEN }}
44+
45+
# Extract metadata (tags, labels) for Docker
46+
# https://github.com/docker/metadata-action
47+
- name: Extract Docker metadata
48+
id: meta
49+
uses: docker/metadata-action@v3
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+
53+
# Build and push Docker image with Buildx (don't push on PR)
54+
# https://github.com/docker/build-push-action
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@v2
57+
with:
58+
context: .
59+
push: ${{ github.event_name != 'pull_request' }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)